-
-
Notifications
You must be signed in to change notification settings - Fork 16k
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
I want to get feature map,but the --visualize argument have some problem 'AttributeError: 'tuple' object has no attribute 'shape'' #12457
Comments
👋 Hello @tiancailin, 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. RequirementsPython>=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 EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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 |
@tiancailin hi there! Thanks for reaching out and for the detailed report. It appears that the issue is related to the |
When run 'python.exe segment/predict.py --visualize' will throw AttributeError: 'tuple' object has no attribute 'shape'
@glenn-jocher |
@tiancailin Thank you for identifying and addressing the issue! Your contribution is greatly appreciated. We'll review your pull request and continue the discussion there. Your input is valuable, and we're grateful for your efforts in improving the project. Keep up the great work! |
👋 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 ⭐ |
* Fix bug in #12457. When run 'python.exe segment/predict.py --visualize' will throw AttributeError: 'tuple' object has no attribute 'shape' * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Fix bug in ultralytics#12457. When run 'python.exe segment/predict.py --visualize' will throw AttributeError: 'tuple' object has no attribute 'shape' * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Search before asking
YOLOv5 Component
Detection
Bug
f:\myWorkDir\yolov5>python segment\predict.py --weights 'myFinished .pt' --source 'myTestImgDir' --data '.\data\myOwnData.yaml' --view-img --visualize --save-txt
segment\predict: weights=['myFinished .pt'], source='myTestImgDir', data='.\data\myOwnData.yaml', imgsz=[640, 640], other default settings , and etc...
YOLOv5 v7.0-218-g9e97ac3 Python-3.10.9 torch-2.0.1+cu118 CUDA:0 (NVIDIA GeForce RTX 3080 Ti, 12287MiB)
Fusing layers...
Model summary: 165 layers, 1879750 parameters, 0 gradients, 6.7 GFLOPs
Saving runs\predict-seg\exp\13_03\stage0_Conv_features.png... (16/16) (<- look ,it works!)
....and continue worked 22 steps, could saved feature maps on disk...
Saving runs\predict-seg\exp\13_03\stage23_C3_features.png... (32/256) (<-problem after this step!)
Traceback (most recent call last):
File "myWorkDir\yolov5\segment\predict.py", line 285, in
main(opt)
File "myWorkDir\yolov5\segment\predict.py", line 280, in main
run(**vars(opt))
File "D:\Programs\Python\Python310\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "myWorkDir\yolov5\segment\predict.py", line 132, in run
pred, proto = model(im, augment=augment, visualize=visualize)[:2]
File "D:\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "myWorkDir\yolov5\models\common.py", line 527, in forward
y = self.model(im, augment=augment, visualize=visualize) if augment or visualize else self.model(im)
File "D:\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "myWorkDir\yolov5\models\yolo.py", line 209, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "myWorkDir\yolov5\models\yolo.py", line 124, in _forward_once
feature_visualization(x, m.type, m.i, save_dir=visualize)
File "myWorkDir\yolov5\utils\plots.py", line 63, in feature_visualization
batch, channels, height, width = x.shape # batch, channels, height, width
AttributeError: 'tuple' object has no attribute 'shape'
Environment
YOLOv5 v7.0-218-g9e97ac3
OS:Win10
Python:3.10.9
Pytorch:2.0.1+cu118(stable version)
GPU:3080Ti
Minimal Reproducible Example
Tried add print(x) and print(type(x)) after
yolov5/utils/plots.py
Line 63 in 3f02fde
In the correct stetp
x =
and
x is a
<class 'torch.Tensor'>
but in the incorrect step
x =
and x is a
<class 'tuple'>
looks like x changed from a single <class 'torch.Size'> to a tuple consisting of multiple <class 'torch.Size'> elements.
so will report
AttributeError: 'tuple' object has no attribute 'shape'
looks like,this x is form this function's return?
https://github.com/ultralytics/yolov5/blob/3f02fdee1d8f1a6cf18a24be3438096466367d9f/models/yolo.py#L114C12-L114C12
Additional
I am not sure the problem came from yolo or pytorch 2.01,because I noticed #3902 , the --visualize should be worked fine after this issue
And I try to change weights file to official
yolov5n-seg.pt
,report the same reportAre you willing to submit a PR?
The text was updated successfully, but these errors were encountered: