Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Instance segmentation on COCO-like dataset: RuntimeError: Masks are expected to be MaskFile objects. #1089

Closed
Borda opened this issue Dec 30, 2021 · 0 comments · Fixed by #1102
Labels
bug / fix Something isn't working help wanted Extra attention is needed

Comments

@Borda
Copy link
Member

Borda commented Dec 30, 2021

🐛 Bug

Trying to run instance segmentation with this fixing PR #1017 on Kaggle competition which provides a dataset in CoCo like format, but getting this strange error and not sure what is the proper "MaskFile objects" as the dataset provides annotation like:

{
 'id': 101439,
 'image_id': 101438,
 'category_id': 1,
 'segmentation': [[281.6, 234.28, 292.24, 236.48, 298.84, 239.04, 305.08, 239.41, 308.38, 239.41, 310.21, 236.11, 310.21, 230.61, 308.75, 226.21, 304.34, 220.71, 302.88, 218.14, 300.68, 214.47, 296.64, 216.3, 288.94, 216.3, 287.11, 219.61, 284.17, 226.94]],
 'area': 492.789049999963,
 'bbox': [281.6, 214.47, 28.609999999999957, 24.939999999999998],
 'iscrowd': 0
}

For sanity adding checking the dataset with

print(f"missing Annot: {[i for i, an in enumerate(data['annotations']) if not an]}")
print(f"missing Segm: {[i for i, an in enumerate(data['annotations']) if not an['segmentation']]}")

which finds nothing suspicious

missing Annot: []
missing Segm: []

To Reproduce

/opt/conda/lib/python3.7/site-packages/flash/core/data/io/input_base.py in _call_load_sample(self, sample)
    149             ),
    150         )
--> 151         return load_sample(copy(sample))
    152 
    153     @staticmethod

/opt/conda/lib/python3.7/site-packages/flash/core/integrations/icevision/data.py in load_sample(self, sample)
     60     def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:
     61         record = sample[DataKeys.INPUT].load()
---> 62         return from_icevision_record(record)
     63 
     64     def predict_load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:

/opt/conda/lib/python3.7/site-packages/flash/core/integrations/icevision/transforms.py in from_icevision_record(record)
    214         sample[DataKeys.INPUT] = record.filepath
    215 
--> 216     sample[DataKeys.TARGET] = from_icevision_detection(record)
    217 
    218     if getattr(record.detection, "class_map", None) is not None:

/opt/conda/lib/python3.7/site-packages/flash/core/integrations/icevision/transforms.py in from_icevision_detection(record)
    160                 result["masks"].append(mask.filepath)
    161             else:
--> 162                 raise RuntimeError("Masks are expected to be MaskFile objects.")
    163 
    164     if hasattr(detection, "keypoints"):

RuntimeError: Masks are expected to be MaskFile objects.

Code sample

See the Kaggle kernel: https://www.kaggle.com/jirkaborovec/cell-instance-segm-lightning-flash?scriptVersionId=83933340

Additional context

@Borda Borda added bug / fix Something isn't working help wanted Extra attention is needed labels Dec 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant