Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash While Using AI Polygons #1335

Open
Erotemic opened this issue Oct 9, 2023 · 0 comments
Open

Crash While Using AI Polygons #1335

Erotemic opened this issue Oct 9, 2023 · 0 comments
Labels
bug issue

Comments

@Erotemic
Copy link

Erotemic commented Oct 9, 2023

Provide environment information

Same env as: #1334

What OS are you using?

Ubuntu 22.04

Describe the Bug

Output I get is:

I was creating a lot of postive and negative anchor points fairly quickly when this crash occurred

MD5 matches: /home/joncrall/.cache/gdown/https-COLON--SLASH--SLASH-github.com-SLASH-wkentaro-SLASH-labelme-SLASH-releases-SLASH-download-SLASH-sam-20230416-SLASH-sam_vit_h_4b8939.quantized.decoder.onnx
Traceback (most recent call last):
  File "/home/joncrall/code/labelme/labelme/widgets/canvas.py", line 773, in paintEvent
    points = self._ai_model.predict_polygon_from_points(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joncrall/code/labelme/labelme/ai/models/segment_anything.py", line 64, in predict_polygon_from_points
    polygon = _compute_polygon_from_points(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joncrall/code/labelme/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
Aborted (core dumped)

It looks like there should be some error handling when countours is empty here.

Expected Behavior

Not crashing.

To Reproduce

I wasn't able to reproduce with random clicks. There must have been something peculiar about the particular shape I made when the crash happened. If I can determine the shape that causes it, I will post back with more details. Either way, from the error we can determine that the assumption that the countours list is non-empty does not hold, and error handling should be added to the code at that point.

@Erotemic Erotemic added the bug issue label Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue
Projects
None yet
Development

No branches or pull requests

1 participant