IDEA-Research / Grounded-Segment-Anything

Grounded SAM: Marrying Grounding DINO with Segment Anything & Stable Diffusion & Recognize Anything - Automatically Detect , Segment and Generate Anything
https://arxiv.org/abs/2401.14159
Apache License 2.0
15.16k stars 1.4k forks source link

when I run python grounded_sam_demo.py I meet new bug #297

Closed Leestronger closed 1 year ago

Leestronger commented 1 year ago

when I run python grounded_sam_demo.py in ubuntu 22.04 , I meet new bug:

/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/torch/functional.py:478: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2894.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
final text_encoder_type: bert-base-uncased
('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
Traceback (most recent call last):
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connectionpool.py", line 714, in urlopen
httplib_response = self._make_request(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connectionpool.py", line 403, in _make_request
self._validate_conn(conn)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1053, in validate_conn
conn.connect()
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connection.py", line 419, in connect
self.sock = ssl_wrap_socket(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/util/ssl.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/util/ssl.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/home/lia/anaconda3/envs/sam/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connectionpool.py", line 798, in urlopen
retries = retries.increment(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/util/retry.py", line 550, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/packages/six.py", line 769, in reraise
raise value.with_traceback(tb)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connectionpool.py", line 714, in urlopen
httplib_response = self._make_request(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connectionpool.py", line 403, in _make_request
self._validate_conn(conn)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1053, in validate_conn
conn.connect()
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/connection.py", line 419, in connect
self.sock = ssl_wrap_socket(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/util/ssl.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/urllib3/util/ssl.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/home/lia/anaconda3/envs/sam/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/transformers/modeling_utils.py", line 1329, in from_pretrained
resolved_archive_file = cached_path(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/transformers/file_utils.py", line 1776, in cached_path
output_path = get_from_cache(
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/transformers/file_utils.py", line 2040, in get_from_cache
http_get(url_to_download, temp_file, proxies=proxies, resume_size=resume_size, headers=headers)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/transformers/file_utils.py", line 1886, in http_get
r = requests.get(url, stream=True, proxies=proxies, headers=headers)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/requests/adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "grounded_sam_demo.py", line 169, in
model = load_model(config_file, grounded_checkpoint, device=device)
File "grounded_sam_demo.py", line 42, in load_model
model = build_model(args)
File "/home/lia/projects/Grounded-Segment-Anything-main/GroundingDINO/groundingdino/models/init.py", line 17, in build_model
model = build_func(args)
File "/home/lia/projects/Grounded-Segment-Anything-main/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 372, in build_groundingdino
model = GroundingDINO(
File "/home/lia/projects/Grounded-Segment-Anything-main/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 108, in init
self.bert = get_tokenlizer.get_pretrained_language_model(text_encoder_type)
File "/home/lia/projects/Grounded-Segment-Anything-main/GroundingDINO/groundingdino/util/get_tokenlizer.py", line 23, in get_pretrained_language_model
return BertModel.from_pretrained(text_encoder_type)
File "/home/lia/anaconda3/envs/sam/lib/python3.8/site-packages/transformers/modeling_utils.py", line 1351, in from_pretrained
raise EnvironmentError(msg)
OSError: Can't load weights for 'bert-base-uncased'. Make sure that:

'bert-base-uncased' is a correct model identifier listed on 'https://huggingface.co/models'
(make sure 'bert-base-uncased' is not a path to a local directory with something else, in that case)

or 'bert-base-uncased' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt
Leestronger commented 1 year ago

linkIt seems that the error is duing to the network

rentainhe commented 1 year ago

Sry for the late reply, it seems your network is not stable when connecting to Huggingface, you can try to download the pretrained bert-base-uncased model to your local directory and set the specific path to it. I'm going to close this issue now, feel free to reopen it if needed