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 on clicking "Create AI-polygons" #1334

Open
Erotemic opened this issue Oct 9, 2023 · 1 comment
Open

Crash on clicking "Create AI-polygons" #1334

Erotemic opened this issue Oct 9, 2023 · 1 comment
Labels
bug issue

Comments

@Erotemic
Copy link

Erotemic commented Oct 9, 2023

Provide environment information

(pyenv3.11.2) joncrall@toothbrush:~$ which python; python --version; python -m pip list | grep labelme
/home/joncrall/.pyenv/versions/3.11.2/envs/pyenv3.11.2/bin/python
Python 3.11.2
labelme                             5.3.1
python -c "import onnxruntime; print('onnxruntime.__version__ = ' + str(onnxruntime.__version__))"
onnxruntime.__version__ = 1.16.0

What OS are you using?

Ubuntu 22.04

Describe the Bug

I'm getting a core dump when I click "Create AI-Polygons":

[INFO   ] __init__:get_config:70 - Loading config file from: /home/joncrall/.labelmerc
Computing MD5: /home/joncrall/.cache/gdown/https-COLON--SLASH--SLASH-github.com-SLASH-wkentaro-SLASH-labelme-SLASH-releases-SLASH-download-SLASH-sam-20230416-SLASH-sam_vit_l_0b3195.quantized.encoder.onnx
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_l_0b3195.quantized.encoder.onnx
Computing MD5: /home/joncrall/.cache/gdown/https-COLON--SLASH--SLASH-github.com-SLASH-wkentaro-SLASH-labelme-SLASH-releases-SLASH-download-SLASH-sam-20230416-SLASH-sam_vit_l_0b3195.quantized.decoder.onnx
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_l_0b3195.quantized.decoder.onnx
Traceback (most recent call last):
  File "/home/joncrall/.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/labelme/app.py", line 373, in <lambda>
    lambda: self.toggleDrawMode(False, createMode="ai_polygon"),
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joncrall/.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/labelme/app.py", line 1071, in toggleDrawMode
    self.canvas.initializeAiModel(
  File "/home/joncrall/.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/labelme/widgets/canvas.py", line 141, in initializeAiModel
    self._ai_model = labelme.ai.SegmentAnythingModel(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joncrall/.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/labelme/ai/models/segment_anything.py", line 19, in __init__
    self._encoder_session = onnxruntime.InferenceSession(encoder_path)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joncrall/.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 432, in __init__
    raise e
  File "/home/joncrall/.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 419, in __init__
    self._create_inference_session(providers, provider_options, disabled_optimizers)
  File "/home/joncrall/.pyenv/versions/3.11.2/envs/pyenv3.11.2/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 451, in _create_inference_session
    raise ValueError(
ValueError: This ORT build has ['AzureExecutionProvider', 'CPUExecutionProvider'] enabled. Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession. For example, onnxruntime.InferenceSession(..., providers=['AzureExecutionProvider', 'CPUExecutionProvider'], ...)
Aborted (core dumped)

It seemed to download the data just fine.

Expected Behavior

not crashing?

To Reproduce

I just did a pip install labelme and did labelme . on a directory of images. Not sure what's causing the issue.

@Erotemic Erotemic added the bug issue label Oct 9, 2023
@Erotemic
Copy link
Author

Erotemic commented Oct 9, 2023

I was able to fix this by adding:

        self._encoder_session = onnxruntime.InferenceSession(encoder_path, providers=['AzureExecutionProvider', 'CPUExecutionProvider'])
        self._decoder_session = onnxruntime.InferenceSession(decoder_path, providers=['AzureExecutionProvider', 'CPUExecutionProvider'])

on lines 19/20 in labelme/ai/models/segment_anything.py

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

Successfully merging a pull request may close this issue.

1 participant