ArielleE commited on
Commit
9b2cae2
1 Parent(s): 8bf9e70

Update Superimposed-Masked-Dataset.py

Browse files
Files changed (1) hide show
  1. Superimposed-Masked-Dataset.py +7 -3
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 = {path: np.load(BytesIO(file.read())) for path, file in mask_archive if path.endswith(".npy")}
 
 
 
 
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 = {