yw26342 commited on
Commit
5cc990e
·
1 Parent(s): e8b2972

Update test.py

Browse files
Files changed (1) hide show
  1. test.py +9 -4
test.py CHANGED
@@ -567,9 +567,15 @@ class Food500(datasets.GeneratorBasedBuilder):
567
  split_metadata_path = dl_manager.download(_METADATA_URL)
568
  metadata = dl_manager.iter_archive(split_metadata_path)
569
  for file_path, file_obj in metadata:
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(
@@ -597,7 +603,6 @@ class Food500(datasets.GeneratorBasedBuilder):
597
 
598
  def _generate_examples(self, images, metadata_set):
599
  """Generate images and labels for splits."""
600
- metadata_set = {path.encode("utf-8") for path 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:
 
567
  split_metadata_path = dl_manager.download(_METADATA_URL)
568
  metadata = dl_manager.iter_archive(split_metadata_path)
569
  for file_path, file_obj in metadata:
570
+ if file_path == _TRAIN_TXT:
571
+ train_set = set(file_obj.read().split("\n"))
572
+ train_set = {path.encode("utf-8") for path in train_set}
573
+ if file_path == _VALID_TXT:
574
+ valid_set = set(file_obj.read().split("\n"))
575
+ valid_set = {path.encode("utf-8") for path in train_set}
576
+ if file_path == _TEST_TXT:
577
+ test_set = set(file_obj.read().split("\n"))
578
+ test_set = {path.encode("utf-8") for path in train_set}
579
  pass
580
  return [
581
  datasets.SplitGenerator(
 
603
 
604
  def _generate_examples(self, images, metadata_set):
605
  """Generate images and labels for splits."""
 
606
  for file_path, file_obj in images:
607
  if file_path.startswith(_IMAGES_DIR):
608
  if file_path[len(_IMAGES_DIR) : -len(".jpg")] in metadata_set: