Update EMT.py
Browse files
EMT.py
CHANGED
|
@@ -225,7 +225,8 @@ class EMT(datasets.GeneratorBasedBuilder):
|
|
| 225 |
)
|
| 226 |
|
| 227 |
def _split_generators(self, dl_manager):
|
| 228 |
-
"""Download
|
|
|
|
| 229 |
image_urls = {
|
| 230 |
"train": _TRAIN_IMAGE_ARCHIVE_URL,
|
| 231 |
"test": _TEST_IMAGE_ARCHIVE_URL,
|
|
@@ -235,38 +236,32 @@ class EMT(datasets.GeneratorBasedBuilder):
|
|
| 235 |
"train": _TRAIN_ANNOTATION_ARCHIVE_URL,
|
| 236 |
"test": _TEST_ANNOTATION_ARCHIVE_URL,
|
| 237 |
}
|
| 238 |
-
|
| 239 |
-
# Download image files
|
| 240 |
-
images = {
|
| 241 |
-
"train": dl_manager.iter_archive(image_urls["train"]),
|
| 242 |
-
"test": dl_manager.iter_archive(image_urls["test"]),
|
| 243 |
-
}
|
| 244 |
|
| 245 |
-
#
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
print("Extracted test annotations path:", annotations["test"])
|
| 253 |
|
| 254 |
return [
|
| 255 |
datasets.SplitGenerator(
|
| 256 |
name=datasets.Split.TRAIN,
|
| 257 |
gen_kwargs={
|
| 258 |
-
"images":
|
| 259 |
-
"annotation_path":
|
| 260 |
},
|
| 261 |
),
|
| 262 |
datasets.SplitGenerator(
|
| 263 |
name=datasets.Split.TEST,
|
| 264 |
gen_kwargs={
|
| 265 |
-
"images":
|
| 266 |
-
"annotation_path":
|
| 267 |
},
|
| 268 |
),
|
| 269 |
-
|
|
|
|
| 270 |
def _generate_examples(self, images, annotation_path):
|
| 271 |
"""Generate dataset examples by matching images to their corresponding annotations."""
|
| 272 |
|
|
|
|
| 225 |
)
|
| 226 |
|
| 227 |
def _split_generators(self, dl_manager):
|
| 228 |
+
"""Download (if not cached) and prepare dataset splits."""
|
| 229 |
+
|
| 230 |
image_urls = {
|
| 231 |
"train": _TRAIN_IMAGE_ARCHIVE_URL,
|
| 232 |
"test": _TEST_IMAGE_ARCHIVE_URL,
|
|
|
|
| 236 |
"train": _TRAIN_ANNOTATION_ARCHIVE_URL,
|
| 237 |
"test": _TEST_ANNOTATION_ARCHIVE_URL,
|
| 238 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
+
# Ensure paths are correctly resolved
|
| 241 |
+
extracted_paths = dl_manager.download_and_extract(annotation_urls)
|
| 242 |
+
image_archives = dl_manager.download_and_extract(image_urls)
|
| 243 |
+
|
| 244 |
+
# ✅ Ensure annotation paths point to the correct subdirectory
|
| 245 |
+
train_annotation_path = os.path.join(extracted_paths["train"], "annotations", "train")
|
| 246 |
+
test_annotation_path = os.path.join(extracted_paths["test"], "annotations", "test")
|
|
|
|
| 247 |
|
| 248 |
return [
|
| 249 |
datasets.SplitGenerator(
|
| 250 |
name=datasets.Split.TRAIN,
|
| 251 |
gen_kwargs={
|
| 252 |
+
"images": dl_manager.iter_archive(image_archives["train"]),
|
| 253 |
+
"annotation_path": train_annotation_path, # ✅ Corrected path
|
| 254 |
},
|
| 255 |
),
|
| 256 |
datasets.SplitGenerator(
|
| 257 |
name=datasets.Split.TEST,
|
| 258 |
gen_kwargs={
|
| 259 |
+
"images": dl_manager.iter_archive(image_archives["test"]),
|
| 260 |
+
"annotation_path": test_annotation_path, # ✅ Corrected path
|
| 261 |
},
|
| 262 |
),
|
| 263 |
+
]
|
| 264 |
+
|
| 265 |
def _generate_examples(self, images, annotation_path):
|
| 266 |
"""Generate dataset examples by matching images to their corresponding annotations."""
|
| 267 |
|