Update test.py
Browse files
test.py
CHANGED
|
@@ -570,32 +570,34 @@ class Food500(datasets.GeneratorBasedBuilder):
|
|
| 570 |
if file_path == _TRAIN_TXT: train_set = set(file_obj.read().split("\n"))
|
| 571 |
if file_path == _VALID_TXT: valid_set = set(file_obj.read().split("\n"))
|
| 572 |
if file_path == _TEST_TXT: test_set = set(file_obj.read().split("\n"))
|
|
|
|
| 573 |
return [
|
| 574 |
datasets.SplitGenerator(
|
| 575 |
name=datasets.Split.TRAIN,
|
| 576 |
gen_kwargs={
|
| 577 |
"images": dl_manager.iter_archive(archive_path),
|
| 578 |
-
"metadata_set":
|
| 579 |
},
|
| 580 |
),
|
| 581 |
datasets.SplitGenerator(
|
| 582 |
name=datasets.Split.VALIDATION,
|
| 583 |
gen_kwargs={
|
| 584 |
"images": dl_manager.iter_archive(archive_path),
|
| 585 |
-
"metadata_set":
|
| 586 |
},
|
| 587 |
),
|
| 588 |
datasets.SplitGenerator(
|
| 589 |
name=datasets.Split.TEST,
|
| 590 |
gen_kwargs={
|
| 591 |
"images": dl_manager.iter_archive(archive_path),
|
| 592 |
-
"metadata_set":
|
| 593 |
},
|
| 594 |
),
|
| 595 |
]
|
| 596 |
|
| 597 |
def _generate_examples(self, images, metadata_set):
|
| 598 |
"""Generate images and labels for splits."""
|
|
|
|
| 599 |
for file_path, file_obj in images:
|
| 600 |
if file_path.startswith(_IMAGES_DIR):
|
| 601 |
if file_path[len(_IMAGES_DIR) : -len(".jpg")] in metadata_set:
|
|
|
|
| 570 |
if file_path == _TRAIN_TXT: train_set = set(file_obj.read().split("\n"))
|
| 571 |
if file_path == _VALID_TXT: valid_set = set(file_obj.read().split("\n"))
|
| 572 |
if file_path == _TEST_TXT: test_set = set(file_obj.read().split("\n"))
|
| 573 |
+
pass
|
| 574 |
return [
|
| 575 |
datasets.SplitGenerator(
|
| 576 |
name=datasets.Split.TRAIN,
|
| 577 |
gen_kwargs={
|
| 578 |
"images": dl_manager.iter_archive(archive_path),
|
| 579 |
+
"metadata_set": train_set,
|
| 580 |
},
|
| 581 |
),
|
| 582 |
datasets.SplitGenerator(
|
| 583 |
name=datasets.Split.VALIDATION,
|
| 584 |
gen_kwargs={
|
| 585 |
"images": dl_manager.iter_archive(archive_path),
|
| 586 |
+
"metadata_set": valid_set,
|
| 587 |
},
|
| 588 |
),
|
| 589 |
datasets.SplitGenerator(
|
| 590 |
name=datasets.Split.TEST,
|
| 591 |
gen_kwargs={
|
| 592 |
"images": dl_manager.iter_archive(archive_path),
|
| 593 |
+
"metadata_set": test_set,
|
| 594 |
},
|
| 595 |
),
|
| 596 |
]
|
| 597 |
|
| 598 |
def _generate_examples(self, images, metadata_set):
|
| 599 |
"""Generate images and labels for splits."""
|
| 600 |
+
metadata_set = {i.encode("utf-8") for str in metadata_set}
|
| 601 |
for file_path, file_obj in images:
|
| 602 |
if file_path.startswith(_IMAGES_DIR):
|
| 603 |
if file_path[len(_IMAGES_DIR) : -len(".jpg")] in metadata_set:
|