KuAvLab commited on
Commit
e4c65e7
·
verified ·
1 Parent(s): 948de27

Update EMT.py

Browse files
Files changed (1) hide show
  1. EMT.py +27 -26
EMT.py CHANGED
@@ -253,15 +253,10 @@ class EMT(datasets.GeneratorBasedBuilder):
253
 
254
  BUILDER_CONFIGS = [
255
  datasets.BuilderConfig(
256
- name="train",
257
  description="Training split of the EMT dataset",
258
  version=datasets.Version("1.0.0"),
259
  ),
260
- datasets.BuilderConfig(
261
- name="test",
262
- description="Test split of the EMT dataset",
263
- version=datasets.Version("1.0.0"),
264
- ),
265
  ]
266
 
267
 
@@ -326,11 +321,9 @@ class EMT(datasets.GeneratorBasedBuilder):
326
  # ),
327
  # ]
328
  def _split_generators(self, dl_manager):
329
- """Download (if not cached) and prepare only the requested dataset split."""
330
-
331
- # Get the requested split
332
- requested_split = self.config.name
333
-
334
  image_urls = {
335
  "train": _TRAIN_IMAGE_ARCHIVE_URL,
336
  "test": _TEST_IMAGE_ARCHIVE_URL,
@@ -340,28 +333,36 @@ class EMT(datasets.GeneratorBasedBuilder):
340
  "train": _TRAIN_ANNOTATION_ARCHIVE_URL,
341
  "test": _TEST_ANNOTATION_ARCHIVE_URL,
342
  }
 
 
 
 
 
 
 
 
343
 
344
- # Validate split name
345
- if requested_split not in image_urls:
346
- raise ValueError(f"Invalid split '{requested_split}'. Available splits: 'train', 'test'.")
347
-
348
- # Extract only the requested split
349
- extracted_images = dl_manager.download_and_extract({requested_split: image_urls[requested_split]})
350
- extracted_annotations = dl_manager.download_and_extract({requested_split: annotation_urls[requested_split]})
351
-
352
- # Define paths based on the requested split
353
- annotation_path = os.path.join(extracted_annotations[requested_split], "annotations", requested_split)
354
- image_path = extracted_images[requested_split]
355
 
 
356
  return [
357
  datasets.SplitGenerator(
358
- name=datasets.Split.TRAIN if requested_split == "train" else datasets.Split.TEST,
 
 
 
 
 
 
 
359
  gen_kwargs={
360
- "image_dir": image_path,
361
- "annotation_path": annotation_path,
362
  },
363
- )
364
  ]
 
365
 
366
 
367
  def _generate_examples(self, images, annotation_path):
 
253
 
254
  BUILDER_CONFIGS = [
255
  datasets.BuilderConfig(
256
+ name="emt",
257
  description="Training split of the EMT dataset",
258
  version=datasets.Version("1.0.0"),
259
  ),
 
 
 
 
 
260
  ]
261
 
262
 
 
321
  # ),
322
  # ]
323
  def _split_generators(self, dl_manager):
324
+ """Download (if not cached) and prepare dataset splits."""
325
+
326
+ # Define dataset URLs
 
 
327
  image_urls = {
328
  "train": _TRAIN_IMAGE_ARCHIVE_URL,
329
  "test": _TEST_IMAGE_ARCHIVE_URL,
 
333
  "train": _TRAIN_ANNOTATION_ARCHIVE_URL,
334
  "test": _TEST_ANNOTATION_ARCHIVE_URL,
335
  }
336
+
337
+ # Extract all data (both splits)
338
+ extracted_images = dl_manager.download_and_extract(image_urls)
339
+ extracted_annotations = dl_manager.download_and_extract(annotation_urls)
340
+
341
+ # Define paths
342
+ train_annotation_path = os.path.join(extracted_annotations["train"], "annotations", "train")
343
+ test_annotation_path = os.path.join(extracted_annotations["test"], "annotations", "test")
344
 
345
+ train_image_path = extracted_images["train"]
346
+ test_image_path = extracted_images["test"]
 
 
 
 
 
 
 
 
 
347
 
348
+ # Return available splits (Hugging Face will filter based on user request)
349
  return [
350
  datasets.SplitGenerator(
351
+ name=datasets.Split.TRAIN,
352
+ gen_kwargs={
353
+ "image_dir": train_image_path,
354
+ "annotation_path": train_annotation_path,
355
+ },
356
+ ),
357
+ datasets.SplitGenerator(
358
+ name=datasets.Split.TEST,
359
  gen_kwargs={
360
+ "image_dir": test_image_path,
361
+ "annotation_path": test_annotation_path,
362
  },
363
+ ),
364
  ]
365
+
366
 
367
 
368
  def _generate_examples(self, images, annotation_path):