Update Superimposed-Masked-Dataset.py
Browse files
Superimposed-Masked-Dataset.py
CHANGED
@@ -74,13 +74,17 @@ class SMD(datasets.GeneratorBasedBuilder):
|
|
74 |
"""Yields examples."""
|
75 |
idx = 0
|
76 |
for archive, mask_archive in zip(archives, mask_archives):
|
77 |
-
mask_files = {
|
|
|
|
|
|
|
|
|
78 |
for path, file in archive:
|
79 |
if path.endswith(".png"):
|
80 |
synset_id = os.path.basename(os.path.dirname(path))
|
81 |
label = IMAGENET2012_CLASSES[synset_id]
|
82 |
-
|
83 |
-
mask_file_path = path.replace(".png", "_mask.npy")
|
84 |
segmentation_mask = mask_files.get(mask_file_path, None)
|
85 |
if segmentation_mask is not None:
|
86 |
ex = {
|
|
|
74 |
"""Yields examples."""
|
75 |
idx = 0
|
76 |
for archive, mask_archive in zip(archives, mask_archives):
|
77 |
+
mask_files = {}
|
78 |
+
for path, file in mask_archive:
|
79 |
+
if path.endswith(".npy"):
|
80 |
+
mask_files[path] = np.load(BytesIO(file.read()))
|
81 |
+
|
82 |
for path, file in archive:
|
83 |
if path.endswith(".png"):
|
84 |
synset_id = os.path.basename(os.path.dirname(path))
|
85 |
label = IMAGENET2012_CLASSES[synset_id]
|
86 |
+
|
87 |
+
mask_file_path = path.replace("_occluded.png", "_mask.npy")
|
88 |
segmentation_mask = mask_files.get(mask_file_path, None)
|
89 |
if segmentation_mask is not None:
|
90 |
ex = {
|