ultralytics / yolov5

YOLOv5 πŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.72k stars 16.12k forks source link

SSL: CERTIFICATE_VERIFY_FAILED while Downloading https://ultralytics.com/assets/Arial.ttf #12306

Closed AnnacKK closed 10 months ago

AnnacKK commented 10 months ago

Search before asking

YOLOv5 Component

Training

Bug

Hi! I am trying to training YOLO on custom dataset (custom.yaml) following tutorial and get error above. I reinstalled anaconda and python, installed certifi library but it didn't work.

!cd yolov5 && python train.py --img 600 --epochs 3 --data custom.yaml --weights yolov5s.pt Error:

train: weights=yolov5s.pt, cfg=, data=custom.yaml, hyp=data\hyps\hyp.scratch-low.yaml, epochs=3, batch_size=16, imgsz=600, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs\train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest
github:  YOLOv5 is out of date by 3 commits. Use 'git pull' or 'git clone https://github.com/ultralytics/yolov5' to update.
YOLOv5  v7.0-228-g4d687c8 Python-3.11.5 torch-2.1.0+cpu CPU

hyperparameters: lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
Comet: run 'pip install comet_ml' to automatically track and visualize YOLOv5  runs in Comet
TensorBoard: Start with 'tensorboard --logdir runs\train', view at http://localhost:6006/
Downloading https://ultralytics.com/assets/Arial.ttf to C:\Users\miran\AppData\Roaming\Ultralytics\Arial.ttf...
Traceback (most recent call last):
  File "C:\anaconda3\Lib\urllib\request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "C:\anaconda3\Lib\http\client.py", line 1286, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\anaconda3\Lib\http\client.py", line 1332, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\anaconda3\Lib\http\client.py", line 1281, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\anaconda3\Lib\http\client.py", line 1041, in _send_output
    self.send(msg)
  File "C:\anaconda3\Lib\http\client.py", line 979, in send
    self.connect()
  File "C:\anaconda3\Lib\http\client.py", line 1458, in connect
    self.sock = self._context.wrap_socket(self.sock,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\Lib\ssl.py", line 517, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\Lib\ssl.py", line 1108, in _create
    self.do_handshake()
  File "C:\anaconda3\Lib\ssl.py", line 1379, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\***\Machine_Learning\Object_Detection\yolov5\train.py", line 647, in <module>
    main(opt)
  File "C:\Users\***\Machine_Learning\Object_Detection\yolov5\train.py", line 536, in main
    train(opt.hyp, opt, device, callbacks)
  File "C:\Users\***\Machine_Learning\Object_Detection\yolov5\train.py", line 117, in train
    data_dict = data_dict or check_dataset(data)  # check if None
                             ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\Machine_Learning\Object_Detection\yolov5\utils\general.py", line 545, in check_dataset
    check_font('Arial.ttf' if is_ascii(data['names']) else 'Arial.Unicode.ttf', progress=True)  # download fonts
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\Machine_Learning\Object_Detection\yolov5\utils\general.py", line 480, in check_font
    torch.hub.download_url_to_file(url, str(file), progress=progress)
  File "C:\Users\***\AppData\Roaming\Python\Python311\site-packages\torch\hub.py", line 620, in download_url_to_file
    u = urlopen(req)
        ^^^^^^^^^^^^
  File "C:\anaconda3\Lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\Lib\urllib\request.py", line 519, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\Lib\urllib\request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\Lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "C:\anaconda3\Lib\urllib\request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\anaconda3\Lib\urllib\request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)>

Environment

-YOLOv5 v7.0-228-g4d687c8 Python-3.11.5 torch-2.1.0+cpu CPU

Minimal Reproducible Example

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)

Additional

Model works fine it use as transfer learning model like this:

model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
img = 'https://media.istockphoto.com/id/148421596/photo/traffic-jam-with-rows-of-cars.jpg?s=612x612&w=0&k=20&c=GeldRtTNo_vMfE7aHxhQY0QoV2DMyzi4LqTOLZL5svc='

results = model(img)

results.print()

Also, cetrifi already installed certifi

Are you willing to submit a PR?

github-actions[bot] commented 10 months ago

πŸ‘‹ Hello @AnnacKK, thank you for your interest in YOLOv5 πŸš€! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a πŸ› Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 πŸš€

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 πŸš€!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics
glenn-jocher commented 10 months ago

@AnnacKK hi,

Thank you for reaching out and reporting the issue. The error you're experiencing, urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)>, is related to the SSL certificate verification for the Arial.ttf font file download.

Please try the following steps to resolve the issue:

  1. Update your YOLOv5 repository by running git pull or cloning it again using git clone https://github.com/ultralytics/yolov5.
  2. Make sure you have the latest version of the certifi library installed. You can update it by running pip install --upgrade certifi.
  3. If the issue still persists, you can try manually downloading the Arial.ttf font file from the Ultralytics website here and placing it in the C:\Users\miran\AppData\Roaming\Ultralytics\ directory.

Please give these steps a try and let me know if the issue is resolved. If not, feel free to provide additional information or ask further questions.

Thank you for your contribution!

Kind regards,

AnnacKK commented 10 months ago

@glenn-jocher Hi! 3 step helped, thank you so much!

glenn-jocher commented 10 months ago

@AnnacKK you're welcome! I'm glad to hear that the issue has been resolved. If you have any more questions or encounter any further issues, feel free to ask for assistance. Great job, and thank you for your understanding and patience.

Kind regards,

Neisser commented 4 months ago

I just had the same problem and Step 3 helped to solve it, @glenn-jocher thankss!

glenn-jocher commented 4 months ago

@Neisser, that's great to hear! If you need any more help or have questions in the future, don't hesitate to reach out. Happy coding! 😊