vietanhdev / anylabeling

Effortless AI-assisted data labeling with AI support from YOLO, Segment Anything (SAM+SAM2), MobileSAM!!
https://anylabeling.nrl.ai
GNU General Public License v3.0
2.2k stars 236 forks source link

Error when downloading certain SAM models #40

Closed tobihanl closed 1 year ago

tobihanl commented 1 year ago

Hi,

I'm trying to label an image with the help of the SAM models, but only some of them work. ViT-B Quant works without problems, but when selecting ViT-L Quant or ViT-H Quant, I'm getting an exception and the program crashes. The full traceback is below. Seems weird, because when I open the link mentioned in the traceback using safari it works.

Any idea what is going wrong here?

(Great job on the tool btw, this is exactly what I was looking for and I'm excited to get it working!!)

Traceback (most recent call last):
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/urllib/request.py", line 1354, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/http/client.py", line 1256, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/http/client.py", line 1302, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/http/client.py", line 1251, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/http/client.py", line 1011, in _send_output
    self.send(msg)
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/http/client.py", line 951, in send
    self.connect()
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/http/client.py", line 1418, in connect
    super().connect()
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/http/client.py", line 922, in connect
    self.sock = self._create_connection(
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/socket.py", line 787, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/site-packages/anylabeling/services/auto_labeling/model.py", line 123, in get_model_abs_path
    urllib.request.urlretrieve(
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/urllib/request.py", line 542, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/urllib/request.py", line 1397, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/urllib/request.py", line 1357, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/site-packages/anylabeling/utils.py", line 15, in run
    self.func(*self.args, **self.kwargs)
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/site-packages/anylabeling/services/auto_labeling/model_manager.py", line 148, in _load_model
    model_info["model"] = SegmentAnything(
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/site-packages/anylabeling/services/auto_labeling/segment_anything.py", line 52, in __init__
    encoder_model_abs_path = self.get_model_abs_path(
  File "/Users/tobias/opt/anaconda3/envs/anylabeling/lib/python3.8/site-packages/anylabeling/services/auto_labeling/model.py", line 128, in get_model_abs_path
    raise Exception(
Exception: Could not download model from https://github.com/vietanhdev/anylabeling-assets/releases/download/v0.2.0/segment_anything_vit_l_encoder_quant.onnx: <urlopen error [Errno 8] nodename nor servname provided, or not known>
vietanhdev commented 1 year ago

Could you provide:

Thank you!

tobihanl commented 1 year ago

Thanks for the quick reply. Looks like your intuition was right, I remember having slow wifi while testing it earlier (don't recall the exact speed unfortunately).

Now with 150Mbps it works without problems. For reference, I'm using

Maybe the error handling for that case could be improved a bit, just as a suggestion. Anyways, thanks for the quick help!

vietanhdev commented 1 year ago

From AnyLabeling v0.2.22, to load custom models: