facebookresearch / Mask2Former

Code release for "Masked-attention Mask Transformer for Universal Image Segmentation"
MIT License
2.59k stars 388 forks source link

RuntimeWarning: invalid value encountered in intersection #171

Open kaitolucifer opened 1 year ago

kaitolucifer commented 1 year ago

When I train the model on my custom dataset , the following warning just kept coming up. Relevant issue is shapely/shapely#1345, but I couldn't find where shapely is used. I thought HungarianMatcher in mask2former/modeling/matcher.py uses it but I couldn't find the exact code.

/opt/conda/envs/pytorch/lib/python3.8/site-packages/shapely/set_operations.py:133: RuntimeWarning: invalid value encountered in intersection
  return lib.intersection(a, b, **kwargs)
pushkalkatara commented 1 year ago

I was also facing this same issue. It relates to the image size of your custom dataset. If you would update the valid image size in the config/augmentation it would fix.

kaitolucifer commented 1 year ago

I was also facing this same issue. It relates to the image size of your custom dataset. If you would update the valid image size in the config/augmentation it would fix.

    # LSJ aug
    cfg.INPUT.IMAGE_SIZE = 1024

Did you mean this image_size in config.py? I’m not using coco_instance_lsj mapper so I don’t think it’s been used.

kaitolucifer commented 1 year ago

I found CropTransform in detectron2 uses shapely. And it calculate the intersection of crop box and annotation’s polygon area. So maybe somehow crop box size was larger than the input image and warnings will pop up.

AndrewTKent commented 1 year ago

I'm using EVA-L and I had this issue pop up this morning but not yesterday when I was running on a different instance. I set up everything the same - maybe there was a recent change to shapely?

Edit: I uninstalled the version of shapely I was using and reverted to an older version (1.8.1 or 1.8.0) and that solved the error message I was getting.