-
-
Notifications
You must be signed in to change notification settings - Fork 16.4k
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
Visualization of feature maps #1067
Comments
Hello @xinxin342, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook , Docker Image, and Google Cloud Quickstart Guide for example environments. 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 model or data training question, please note Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:
For more information please visit https://www.ultralytics.com. |
@xinxin342 we are open to PRs, so if you would like to work on this and submit a PR we'd be happy to review! |
Sorry, I'm completely out of my depth, but I see that it looks like YOLOv4 can do this. |
@xinxin342 feature map visualization is something you can inject into the model forward function at the location of your choosing. It's up to you exactly where in the model you'd want to visualize this, as there are hundreds of layers and thousands of maps. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@xinxin342 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 🚀! |
Can you tell me more about how to implement the feature maps functionality? I assumed from above that, if we're after the SPP layer, we just needed to go into yolo.py and change visualize=False to True in: def _forward_once(self, x, profile=False, visualize=True). Clearly this isn't enough. What am I missing? |
@MLDavies 👋 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! |
Perfect. Love yolov5! Ya, I was (mistakenly) trying to call --visualize on train.py rather than detect.py. Thanks for what you do, and for your responses. |
@glenn-jocher I run the following script |
@wanglegoc --visualize works correctly. I just tested right now: |
@glenn-jocher can we use this feature for yolov4 architecture ? if not what are the changes to be made to the code |
@abhigoku10 The feature map visualization is specific to the YOLOv5 architecture and is not directly compatible with YOLOv4. Porting this feature to YOLOv4 would require significant modifications to the codebase, including changes to the network architecture, model forward method, and visualization logic. If you are interested in adding feature map visualization to YOLOv4, I recommend referring to the YOLOv5 implementation as a reference and making the necessary adaptations to the YOLOv4 codebase. Good luck! |
🚀 Feature
Maybe we can add one more function to Yolov5 that can conveniently show the feature maps of convolutional layers and detection layers?
Motivation
Pitch
So we can visually see where the model's attention is.
Alternatives
Additional context
The text was updated successfully, but these errors were encountered: