siavava commited on
Commit
82ba351
1 Parent(s): 4441c84

Update mmod2.py

Browse files
Files changed (1) hide show
  1. mmod2.py +38 -26
mmod2.py CHANGED
@@ -47,35 +47,47 @@ class Mmod2(datasets.GeneratorBasedBuilder):
47
  # task_templates=[datasets.ImageClassification(image_column="image", label_column="label")],
48
  )
49
 
50
- def _split_generators(self, dl_manager):
51
- # archive_path = dl_manager.download(_BASE_URL)
52
- print("0000000")
53
- split_metadata_paths = dl_manager.download(_METADATA_URLS)
54
- # print(f"{split_metadata_paths = }")
55
- self.data_dir = dl_manager.download_and_extract(_BASE_URL)
56
- with open(split_metadata_paths[0], encoding="utf-8") as f:
57
- train_files = set(f.read().split("\n"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
- with open(split_metadata_paths[1], encoding="utf-8") as f:
60
- validation_files = set(f.read().split("\n"))
61
 
62
  return [
63
- datasets.SplitGenerator(
64
- name=datasets.Split.TRAIN,
65
- gen_kwargs={
66
- "split_key": "train",
67
- "images": train_files,
68
- "metadata_path": split_metadata_paths[0],
69
- },
70
- ),
71
- datasets.SplitGenerator(
72
- name=datasets.Split.VALIDATION,
73
- gen_kwargs={
74
- "split_key": "validation",
75
- "images": validation_files,
76
- "metadata_path": split_metadata_paths[1],
77
- },
78
- ),
79
  ]
80
 
81
  def _generate_examples(self, images, metadata_path=None, split_key="train"):
 
47
  # task_templates=[datasets.ImageClassification(image_column="image", label_column="label")],
48
  )
49
 
50
+ # def _split_generators(self, dl_manager):
51
+ # # archive_path = dl_manager.download(_BASE_URL)
52
+ # print("0000000")
53
+ # split_metadata_paths = dl_manager.download(_METADATA_URLS)
54
+ # # print(f"{split_metadata_paths = }")
55
+ # self.data_dir = dl_manager.download_and_extract(_BASE_URL)
56
+ # with open(split_metadata_paths[0], encoding="utf-8") as f:
57
+ # train_files = set(f.read().split("\n"))
58
+
59
+ # with open(split_metadata_paths[1], encoding="utf-8") as f:
60
+ # validation_files = set(f.read().split("\n"))
61
+
62
+ # return [
63
+ # datasets.SplitGenerator(
64
+ # name=datasets.Split.TRAIN,
65
+ # gen_kwargs={
66
+ # "split_key": "train",
67
+ # "images": train_files,
68
+ # "metadata_path": split_metadata_paths[0],
69
+ # },
70
+ # ),
71
+ # datasets.SplitGenerator(
72
+ # name=datasets.Split.VALIDATION,
73
+ # gen_kwargs={
74
+ # "split_key": "validation",
75
+ # "images": validation_files,
76
+ # "metadata_path": split_metadata_paths[1],
77
+ # },
78
+ # ),
79
+ # ]
80
 
81
+ def _split_generators(self, dl_manager):
82
+ archive = dl_manager.download(_DATA_URL)
83
 
84
  return [
85
+ datasets.SplitGenerator(
86
+ name=datasets.Split.TRAIN, gen_kwargs={"images": dl_manager.iter_archive(archive), "split": "train"}
87
+ ),
88
+ datasets.SplitGenerator(
89
+ name=datasets.Split.VALIDATION, gen_kwargs={"images": dl_manager.iter_archive(archive), "split": "validation"}
90
+ ),
 
 
 
 
 
 
 
 
 
 
91
  ]
92
 
93
  def _generate_examples(self, images, metadata_path=None, split_key="train"):