labelmeai / labelme

Image Polygonal Annotation with Python (polygon, rectangle, circle, line, point and image-level flag annotation).
https://labelme.io
Other
13.11k stars 3.37k forks source link

LabelMe Crashes with SegmentAnything Model (Speed Version) for Automatic Annotation #1387

Closed dnyanshwalwadkar closed 8 months ago

dnyanshwalwadkar commented 8 months ago

Provide environment information

Python 3.10.0 Labelme 5.3.1

What OS are you using?

macOS Sanoma 14.0

Describe the Bug

When attempting to use the SegmentAnything model (speed version) for automatic annotation in LabelMe, the software crashes and the program closes abruptly. However, using the balanced and accuracy models of SegmentAnything does not cause any issues.

Error : Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/labelme/widgets/canvas.py", line 773, in paintEvent points = self._ai_model.predict_polygon_from_points( File "/usr/local/lib/python3.10/site-packages/labelme/ai/models/segment_anything.py", line 64, in predict_polygon_from_points polygon = _compute_polygon_from_points( File "/usr/local/lib/python3.10/site-packages/labelme/ai/models/segment_anything.py", line 172, in _compute_polygon_from_points contour = max(contours, key=_get_contour_length) ValueError: max() arg is an empty sequence [1] 30792 abort labelme

Expected Behavior

I expected LabelMe to perform automatic annotation using the SegmentAnything model (speed version) without crashing, similar to how it behaves with the balanced and accuracy models.

To Reproduce

  1. Open LabelMe. ( 5.3.1)
  2. Load any image and use Segment Anything ( Speed ) model to get annotations.
  3. Click on image to get segmentation annotation.
  4. Wait for sometime to model processing.
  5. As this completed, immediately observe that the software crashes, without showing annotations or allowing us to edit or modify.