Skip to content
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

Error running python detect.py --visualize #5503

Closed
1 task done
ys31jp opened this issue Nov 4, 2021 · 8 comments
Closed
1 task done

Error running python detect.py --visualize #5503

ys31jp opened this issue Nov 4, 2021 · 8 comments
Labels
question Further information is requested

Comments

@ys31jp
Copy link
Contributor

ys31jp commented Nov 4, 2021

Search before asking

Question

python detect.py --visualize

image 1/1 E:\Documents\yolov5_ver6_no_modify\yolov5-master\data\data_remove\image.jpg: Saving runs\detect\exp6\image\stage0_Conv_features.png... (32/32)
Traceback (most recent call last):
File "detect.py", line 307, in
main(opt)
File "detect.py", line 302, in main
run(**vars(opt))
File "E:\anaconda3\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "detect.py", line 151, in run
pred = model(img, augment=augment, visualize=visualize)[0]
File "E:\anaconda3\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "E:\Documents\yolov5_ver6_no_modify\yolov5-master\models\yolo.py", line 126, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "E:\Documents\yolov5_ver6_no_modify\yolov5-master\models\yolo.py", line 152, in _forward_once
feature_visualization(x, m.type, m.i, save_dir=visualize)
File "E:\Documents\yolov5_ver6_no_modify\yolov5-master\utils\plots.py", line 446, in feature_visualization
plt.savefig(save_dir / f, dpi=300, bbox_inches='tight')
File "E:\anaconda3\lib\site-packages\matplotlib\pyplot.py", line 859, in savefig
res = fig.savefig(*args, **kwargs)
File "E:\anaconda3\lib\site-packages\matplotlib\figure.py", line 2311, in savefig
self.canvas.print_figure(fname, **kwargs)
File "E:\anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 2210, in print_figure
result = print_method(
File "E:\anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 1639, in wrapper
return func(*args, **kwargs)
File "E:\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 510, in print_png
mpl.image.imsave(
File "E:\anaconda3\lib\site-packages\matplotlib\image.py", line 1605, in imsave
image.save(fname, **pil_kwargs)
File "E:\anaconda3\lib\site-packages\PIL\Image.py", line 2148, in save
fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: 'runs\detect\exp6\image\stage0_Conv_features.png'

Hi, I have this error when I run detect.py --visualize.
Any ideas why I have this error?

Additional

No response

@ys31jp ys31jp added the question Further information is requested label Nov 4, 2021
@glenn-jocher
Copy link
Member

glenn-jocher commented Nov 4, 2021

@ys31jp 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. We've tried to reproduce this issue but everything works correctly for us using your commands:

Screen Shot 2021-11-04 at 3 43 45 PM

We've created a few short guidelines below to help users provide what we need in order to get started investigating a possible problem.

How to create a Minimal, Reproducible Example

When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:

  • Minimal – Use as little code as possible to produce the problem
  • Complete – Provide all parts someone else needs to reproduce the problem
  • Reproducible – Test the code you're about to provide to make sure it reproduces the problem

For Ultralytics to provide assistance your code should also be:

  • Current – Verify that your code is up-to-date with GitHub master, and if necessary git pull or git clone a new copy to ensure your problem has not already been solved in master.
  • Unmodified – Your problem must be reproducible using official YOLOv5 code without changes. Ultralytics does not provide support for custom code ⚠️.

If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.

Thank you! 😃

@Zengyf-CVer
Copy link
Contributor

@ys31jp
It may be a path problem in the windows operating system, so you should modify it appropriately. This does not exist on Mac and Linux.

@ys31jp
Copy link
Contributor Author

ys31jp commented Nov 5, 2021

Hi, thanks for prompt response. I test again. If I test with
python detect.py --visualize --source data/image.jpg
It work and nothing issues.

However if I test with
python detect.py --visualize --source data/image_0123.fr0123.jpg
The error will occurs.

image 1/1 E:\Documents\yolov5_ver6_no_modify\yolov5-master\data\image.jpg: Saving runs\detect\exp6\image_0123.fr0123\stage0_Conv_features.png... (32/32)
Traceback (most recent call last):
File "detect.py", line 307, in
main(opt)
File "detect.py", line 302, in main
run(**vars(opt))
File "E:\anaconda3\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "detect.py", line 151, in run
pred = model(img, augment=augment, visualize=visualize)[0]
File "E:\anaconda3\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "E:\Documents\yolov5_ver6_no_modify\yolov5-master\models\yolo.py", line 126, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "E:\Documents\yolov5_ver6_no_modify\yolov5-master\models\yolo.py", line 152, in _forward_once
feature_visualization(x, m.type, m.i, save_dir=visualize)
File "E:\Documents\yolov5_ver6_no_modify\yolov5-master\utils\plots.py", line 446, in feature_visualization
plt.savefig(save_dir / f, dpi=300, bbox_inches='tight')
File "E:\anaconda3\lib\site-packages\matplotlib\pyplot.py", line 859, in savefig
res = fig.savefig(*args, **kwargs)
File "E:\anaconda3\lib\site-packages\matplotlib\figure.py", line 2311, in savefig
self.canvas.print_figure(fname, **kwargs)
File "E:\anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 2210, in print_figure
result = print_method(
File "E:\anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 1639, in wrapper
return func(*args, **kwargs)
File "E:\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 510, in print_png
mpl.image.imsave(
File "E:\anaconda3\lib\site-packages\matplotlib\image.py", line 1605, in imsave
image.save(fname, **pil_kwargs)
File "E:\anaconda3\lib\site-packages\PIL\Image.py", line 2148, in save
fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: 'runs\detect\exp6\image_0123.fr0123\stage0_Conv_features.png'

#Zengyf-CVer Yes. It was due to the path issues.
if the image name is image_0123.fr0123.jpg in both Window and Ubuntu, it will generate the same error.

Because all of image name is somethings like this image_0123.fr0123. I have try to fixed this to check the feature map.
@glenn-jocher I implement this to fixed the issues. In plots.py, feature_visualization line 446 - 448.
I do test on both image name (image.jpg & image_0123.fr0123.jpg) and it works.

image

@Zengyf-CVer
Copy link
Contributor

@ys31jp
Try to avoid the decimal point "." in the image name:
image_0123.fr0123.jpg

@ys31jp
Copy link
Contributor Author

ys31jp commented Nov 5, 2021

@ys31jp Try to avoid the decimal point "." in the image name: image_0123.fr0123.jpg

I cant. I have few k of dataset images with the ".". Which impossible for me to avoid.

@glenn-jocher
Copy link
Member

glenn-jocher commented Nov 5, 2021

@ys31jp can you please submit a Pull Request with your fix to help other users? Thanks!

Please see our ✅ Contributing Guide to get started.

glenn-jocher added a commit that referenced this issue Nov 5, 2021
Fix for #5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```
@glenn-jocher
Copy link
Member

@ys31jp good news 😃! Your original issue may now be fixed ✅ in PR #5518. This PR updates increment_path() to correctly handle multi-suffix filenames.

To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

glenn-jocher added a commit that referenced this issue Nov 5, 2021
Fix for #5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```
ys31jp added a commit to ys31jp/yolov5 that referenced this issue Nov 5, 2021
Error running python detect.py --visualize
ultralytics#5503
@ys31jp
Copy link
Contributor Author

ys31jp commented Nov 5, 2021

Hi @glenn-jocher I've pull request for this issues. Not sure am I do it correctly. Thanks for the response. Thanks for your team too.

glenn-jocher added a commit that referenced this issue Nov 5, 2021
* Update plots.py

Error running python detect.py --visualize
#5503

* Update plots.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@ys31jp ys31jp closed this as completed Nov 5, 2021
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this issue Aug 26, 2022
Fix for ultralytics#5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this issue Aug 26, 2022
* Update plots.py

Error running python detect.py --visualize
ultralytics#5503

* Update plots.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
SecretStar112 added a commit to SecretStar112/yolov5 that referenced this issue May 24, 2023
Fix for ultralytics/yolov5#5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants