YOLOv5 Loading Error

ammar_siddiqui: <pre><code class="lang-auto">import torch

# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
</code></pre>
<p>While executing the above code, I am getting this exception:</p>
<pre><code class="lang-auto">Using cache found in /home/aidev/.cache/torch/hub/ultralytics_yolov5_master
YOLOv5 🚀 2023-9-14 Python-3.10.13 torch-2.0.1+cu117 CUDA:0 (NVIDIA GeForce 940MX, 4044MiB)

Traceback (most recent call last):
  File "/home/aidev/.cache/torch/hub/ultralytics_yolov5_master/hubconf.py", line 49, in _create
    model = DetectMultiBackend(path, device=device, fuse=autoshape)  # detection model
  File "/home/aidev/.cache/torch/hub/ultralytics_yolov5_master/models/common.py", line 356, in __init__
    model = attempt_load(weights if isinstance(weights, list) else w, device=device, inplace=True, fuse=fuse)
  File "/home/aidev/.cache/torch/hub/ultralytics_yolov5_master/models/experimental.py", line 79, in attempt_load
    ckpt = torch.load(attempt_download(w), map_location='cpu')  # load
  File "/home/aidev/anaconda3/envs/person_count/lib/python3.10/site-packages/torch/serialization.py", line 797, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "/home/aidev/anaconda3/envs/person_count/lib/python3.10/site-packages/torch/serialization.py", line 283, in __init__
    super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/aidev/.cache/torch/hub/ultralytics_yolov5_master/hubconf.py", line 60, in _create
    model = attempt_load(path, device=device, fuse=False)  # arbitrary model
  File "/home/aidev/.cache/torch/hub/ultralytics_yolov5_master/models/experimental.py", line 79, in attempt_load
    ckpt = torch.load(attempt_download(w), map_location='cpu')  # load
  File "/home/aidev/anaconda3/envs/person_count/lib/python3.10/site-packages/torch/serialization.py", line 797, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "/home/aidev/anaconda3/envs/person_count/lib/python3.10/site-packages/torch/serialization.py", line 283, in __init__
    super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

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

Traceback (most recent call last):
  File "/home/aidev/VectraCom/crowd_count/counter_yolo.py", line 4, in &lt;module&gt;
    model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
  File "/home/aidev/anaconda3/envs/person_count/lib/python3.10/site-packages/torch/hub.py", line 558, in load
    model = _load_local(repo_or_dir, model, *args, **kwargs)
  File "/home/aidev/anaconda3/envs/person_count/lib/python3.10/site-packages/torch/hub.py", line 587, in _load_local
    model = entry(*args, **kwargs)
  File "/home/aidev/.cache/torch/hub/ultralytics_yolov5_master/hubconf.py", line 93, in yolov5s
    return _create('yolov5s', pretrained, channels, classes, autoshape, _verbose, device)
  File "/home/aidev/.cache/torch/hub/ultralytics_yolov5_master/hubconf.py", line 78, in _create
    raise Exception(s) from e
Exception: PytorchStreamReader failed reading zip archive: failed finding central directory. Cache may be out of date, try `force_reload=True` or see https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_model_loading for help.
</code></pre>