Update mhr_recognize_datasets.py
Browse files- mhr_recognize_datasets.py +10 -7
mhr_recognize_datasets.py
CHANGED
|
@@ -51,25 +51,28 @@ class MHRRecognizeDatasets(datasets.GeneratorBasedBuilder):
|
|
| 51 |
def _split_generators(self, dl_manager):
|
| 52 |
"""Returns SplitGenerators."""
|
| 53 |
download_files = dl_manager.download_and_extract(_DATA_URL)
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
return [
|
| 56 |
datasets.SplitGenerator(
|
| 57 |
name=datasets.Split.TRAIN,
|
| 58 |
gen_kwargs={
|
| 59 |
-
"
|
| 60 |
-
"
|
| 61 |
},
|
| 62 |
)
|
| 63 |
]
|
| 64 |
|
| 65 |
-
def _generate_examples(self,
|
| 66 |
-
print("1:",
|
| 67 |
if True:
|
| 68 |
# if self.config.name == "whole":
|
| 69 |
# Read csv with image labels
|
| 70 |
-
label_csv = pd.read_csv(
|
| 71 |
print("2:", label_csv)
|
| 72 |
-
for i, path in enumerate(
|
| 73 |
file_name = os.path.basename(path)
|
| 74 |
print("3:", i, path, file_name)
|
| 75 |
# Get image id to filter the respective row of the csv
|
|
|
|
| 51 |
def _split_generators(self, dl_manager):
|
| 52 |
"""Returns SplitGenerators."""
|
| 53 |
download_files = dl_manager.download_and_extract(_DATA_URL)
|
| 54 |
+
name = self.config.name
|
| 55 |
+
images = dl_manager.iter_files(os.path.join(download_files[name+"_image"]))
|
| 56 |
+
label = os.path.join(download_files[name+"_label"])
|
| 57 |
+
print(download_files, images, label)
|
| 58 |
return [
|
| 59 |
datasets.SplitGenerator(
|
| 60 |
name=datasets.Split.TRAIN,
|
| 61 |
gen_kwargs={
|
| 62 |
+
"images": images,
|
| 63 |
+
"label": label,
|
| 64 |
},
|
| 65 |
)
|
| 66 |
]
|
| 67 |
|
| 68 |
+
def _generate_examples(self, images, label):
|
| 69 |
+
print("1:", images, label_path)
|
| 70 |
if True:
|
| 71 |
# if self.config.name == "whole":
|
| 72 |
# Read csv with image labels
|
| 73 |
+
label_csv = pd.read_csv(label)
|
| 74 |
print("2:", label_csv)
|
| 75 |
+
for i, path in enumerate(images):
|
| 76 |
file_name = os.path.basename(path)
|
| 77 |
print("3:", i, path, file_name)
|
| 78 |
# Get image id to filter the respective row of the csv
|