ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.65k stars 16.11k forks source link

YOLOV5 segmentation can not run without internet connection #12258

Closed anewworl closed 9 months ago

anewworl commented 11 months ago

Search before asking

YOLOv5 Component

No response

Bug

YOLOv5  2023-10-13 Python-3.9.13 torch-2.0.1+cu118 CUDA:0 (NVIDIA GeForce RTX 3050 Ti Laptop GPU, 4096MiB)

Traceback (most recent call last):
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\util\connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "C:\Users\phann\AppData\Local\Programs\Python\Python39\lib\socket.py", line 954, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\connection.py", line 358, in connect
    self.sock = conn = self._new_conn()
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x0000023F3D95F220>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\requests\adapters.py", line 486, in send
    resp = conn.urlopen(
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/best.pt/tree/main?recursive=True&expand=False (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000023F3D95F220>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\train_seg.py", line 4, in <module>
    run(weights='best.pt',data='data.yaml', source=1, view_img=True)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\yolov5\segment\predict.py", line 110, in run
    model = DetectMultiBackend(weights, device=device, dnn=dnn, data=data, fp16=half)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\yolov5\models\common.py", line 338, in __init__
    result = attempt_download_from_hub(w, hf_token=hf_token)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\yolov5\utils\downloads.py", line 154, in attempt_download_from_hub
    repo_files = list_repo_files(repo_id=repo_id, repo_type='model', token=hf_token)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\huggingface_hub\utils\_deprecation.py", line 103, in inner_f
    return f(*args, **kwargs)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\huggingface_hub\utils\_validators.py", line 118, in _inner_fn
    return fn(*args, **kwargs)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\huggingface_hub\hf_api.py", line 2089, in list_repo_files
    return [
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\huggingface_hub\hf_api.py", line 2089, in <listcomp>
    return [
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\huggingface_hub\hf_api.py", line 2055, in list_files_info
    for subpath_info in paginate(path=tree_url, headers=headers, params={"recursive": True, "expand": expand}):
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\huggingface_hub\utils\_pagination.py", line 35, in paginate
    r = session.get(path, params=params, headers=headers)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\requests\sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\huggingface_hub\utils\_http.py", line 63, in send
    return super().send(request, *args, **kwargs)
  File "D:\HOC_TAP\YASKAWA\YOLO_PyCharm\3.Training\venv\lib\site-packages\requests\adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/best.pt/tree/main?recursive=True&expand=False (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000023F3D95F220>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))"), '(Request ID: 835cbe2c-91d5-4d38-a6b1-f904a3720ace)')

Environment

No response

Minimal Reproducible Example

from yolov5.segment.predict import run

run(weights='best.pt',data='data.yaml', source=1, view_img=True)

Additional

So when i run the yolov5 segmentation predict file with out the internet connection the error above seem to be appeared. I don't know if this is a feature or a bug. I have try to run the same code with yolov5/detect.py but it seem to run fine without the internet connection.

Are you willing to submit a PR?

glenn-jocher commented 11 months ago

@anewworl this error seems to be related to a connection issue when running the YOLOv5 segmentation predict file without an internet connection. The error trace indicates that there is a failure to establish a connection with 'huggingface.co'.

The YOLOv5 segmentation predict file may require an internet connection to download certain resources or models from external sources. If you're unable to establish an internet connection, it can lead to this error.

To resolve this issue, ensure that you have an active internet connection when running the YOLOv5 segmentation predict file. Alternatively, you can check if there are alternative ways to provide the required resources or models offline.

Please note that YOLOv5 is an open-source project developed by the YOLO community and maintained by the Ultralytics team. If you encounter any further issues or have any other questions, feel free to ask. Contributions in the form of a pull request are also welcome!

Thank you for your contribution and support in improving YOLOv5!

github-actions[bot] commented 10 months ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐