-
-
Notifications
You must be signed in to change notification settings - Fork 16.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue regarding: "cannot identify image file '/content/drive/MyDrive/Data/test/images/00705.jpg'" #13318
Comments
👋 Hello @MHassanlatif, thank you for reaching out about your issue with YOLOv5 🚀! This is an automated response to get you started, and an Ultralytics engineer will assist you soon. It seems you're encountering an In the meantime, you might find the following resources helpful:
To get started with YOLOv5: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 can be run in various environments:
New FeatureExplore YOLOv8 for state-of-the-art object detection 🚀: pip install ultralytics Please let us know if you have any more information or questions. A team member will be with you shortly to provide further assistance. 😊 |
I tried these things again and again but i get the same problem. |
@MHassanlatif please ensure your image file is not corrupted and is in a supported format. You might also try opening the image with a different tool to verify its integrity. If the issue persists, consider updating to the latest YOLOv5 version and re-testing. |
@glenn-jocher Yeah i already sorted out this problem yesterday and the problem was that the images are corrupted. |
Great to hear you resolved the issue. If you have any more questions or need further assistance, feel free to ask. |
Search before asking
Question
Hi everyone
I am facing some problem regarding the inference model every time when i run the inference on my data it provides the error that the model didn't identify the image can anyone guide me regarding this @glenn-jocher.
Here is the code which i used:
"import torch
from pathlib import Path
import cv2
from google.colab import drive
drive.mount('/content/drive')
weight_path = '/content/drive/MyDrive/Data/runs/train/exp_100_epoch/weights/best.pt'
Load the custom YOLOv5 model
model = torch.hub.load('ultralytics/yolov5', 'custom', path=weight_path)
img = "/content/drive/MyDrive/Data/test/images/00705.jpg" # or file, Path, PIL, OpenCV, numpy, list
results = model(img)
results.print()"
And the error which i get here:
"Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force_remount=True).
Using cache found in /root/.cache/torch/hub/ultralytics_yolov5_master
YOLOv5 🚀 2024-9-16 Python-3.10.12 torch-2.4.0+cu121 CPU
Fusing layers...
YOLOv5n6 summary: 206 layers, 3096916 parameters, 0 gradients, 4.2 GFLOPs
Adding AutoShape...
UnidentifiedImageError Traceback (most recent call last)
in <cell line: 49>()
47
48 # Inference
---> 49 results = model(img)
50
51 # Results
4 frames
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in _wrapped_call_impl(self, *args, **kwargs)
1551 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1552 else:
-> 1553 return self._call_impl(*args, **kwargs)
1554
1555 def _call_impl(self, *args, **kwargs):
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in _call_impl(self, *args, **kwargs)
1560 or _global_backward_pre_hooks or _global_backward_hooks
1561 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1562 return forward_call(*args, **kwargs)
1563
1564 try:
/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py in decorate_context(*args, **kwargs)
114 def decorate_context(*args, **kwargs):
115 with ctx_factory():
--> 116 return func(*args, **kwargs)
117
118 return decorate_context
~/.cache/torch/hub/ultralytics_yolov5_master/models/common.py in forward(self, ims, size, augment, profile)
872 f = f"image{i}" # filename
873 if isinstance(im, (str, Path)): # filename or uri
--> 874 im, f = Image.open(requests.get(im, stream=True).raw if str(im).startswith("http") else im), im
875 im = np.asarray(exif_transpose(im))
876 elif isinstance(im, Image.Image): # PIL Image
/usr/local/lib/python3.10/dist-packages/PIL/Image.py in open(fp, mode, formats)
3281 raise TypeError(msg) from e
3282 else:
-> 3283 rawmode = mode
3284 if mode in ["1", "L", "I", "P", "F"]:
3285 ndmax = 2
UnidentifiedImageError: cannot identify image file '/content/drive/MyDrive/Data/test/images/00705.jpg'"
Additional
No response
The text was updated successfully, but these errors were encountered: