-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
How to visualize feature mapping on YOLOV5s? #3089
Comments
👋 Hello @Mashood3624, 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 screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com. RequirementsPython 3.8 or later with all requirements.txt dependencies installed, including $ pip install -r requirements.txt 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 (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
@Mashood3624 you should be able to visualize data anywhere in the model by inserting your own plotting routines wherever you want. The model forward method is probably a good place to start: Lines 72 to 118 in 525f4f8
|
I tried it and it worked! thanks 👍
|
Oh great! Though I think there may be a bug in your plotting code, as the feature maps lack any concept of RGB or BGR 'colors'. You may have confused the anchor dimension for a color dimension. |
@thanhphuchuynh the feature maps have no concept of RGB or BGR as I said, but your images are in color. The channel dimension that inputs 3 colors is stretched to over a thousand channels eventually, but none of them are paired in 3s for color. |
@thanhphuchuynh interesting! |
Hello, I'm a novice. I'd like to ask you, where should the visual code you disclose be inserted? |
In the model forward method, you should custom again code. |
Have you understand how to plot the feature maps? |
yes, I know. 应该是在前向传播中添加可视化程序即可。 |
Hi, I have tried implementing feature maps from @thanhphuchuynh repo but It dont look great. @glenn-jocher Can you confirm if it is right or not ? here is some pictures |
@Mashood3624 thats incorrect. Feature maps are square for 640x640 inputs and there are more than a thousand of them in a YOLOv5l output. |
@Mashood3624 good news 😃! Feature map visualization was added ✅ in PR #3804 by @Zigars today. This allows for visualizing feature maps from any part of the model from any function (i.e. detect.py, train.py, test.py). Feature maps are saved as *.png files in runs/features/exp directory. To turn on feature visualization set Lines 158 to 160 in 20d45aa
To receive this update:
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 🚀! |
Thank you @glenn-jocher 😊 |
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
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 YOLOv5 🚀 and Vision AI ⭐! |
1, I realize that below |
@ZiyuBao making directories is handled in detect.py here: Lines 113 to 114 in 2d99063
matplotlib is actually placed in a mode where it doesn't produce any windows here, so I think we can skip plt.close() calls Lines 20 to 22 in 2d99063
|
Hi, how can we visualize class probability map after detection? |
👋 Hello! Thanks for asking about feature visualization. YOLOv5 🚀 features can be visualized through all stages of the model from input to output. To visualize features from a given source run python detect.py --weights yolov5s.pt --source data/images/bus.jpg --visualize An example Notebook visualizing bus.jpg features with YOLOv5s is shown below: All stages are visualized by default, each with its own PNG showing the first 32 feature maps output from that stage. You can open any PNG for a closer look. For example the first 32 feature maps of the Focus() layer output are shown in Feature maps may be customized by updating the Lines 403 to 427 in bb5ebc2
Good luck 🍀 and let us know if you have any other questions! |
Hi, Thanks for your reply. |
@noreenanwar class probability vectors are stripped in the NMS function, you can access the full vectors there: Lines 776 to 875 in 0c13240
|
I should add the following lines in this file?. visualize = increment_path(save_dir / Path(path).stem, mkdir=True) if visualize else False |
@noreenanwar yes, you can customize the visualization output by adding those lines to the file. Make sure to also define the |
how did you make changes to this can you show me step by step i dont understand what you did to make feature map |
❔Question
I have been searching for hours but I cannot find a single repo or issue on github which tells how can we visualize feature maps of a yolo model.
Sample:
Additional context
The text was updated successfully, but these errors were encountered: