Skip to content

Print imgsz information along with FLOPs #16955

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Y-T-G
Copy link
Collaborator

@Y-T-G Y-T-G commented Oct 16, 2024

FLOPs value is connected to imgsz, so print that alongside GFLOPs. Avoids confusion like in #16919 (comment)

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhances model summary output with additional image size information in FLOPs calculation.

📊 Key Changes

  • Updated the model_info function to include image size (imgsz) in the model's GFLOPs (Giga Floating Point Operations) output.

🎯 Purpose & Impact

  • Improved Transparency: Provides users with more specific details about the FLOPs calculation by including the image size, making model performance evaluation clearer. 📈
  • Enhanced Clarity: Helps users better understand how image size affects model complexity and resource requirements. 🖼️

@UltralyticsAssistant UltralyticsAssistant added the enhancement New feature or request label Oct 16, 2024
@UltralyticsAssistant
Copy link
Member

👋 Hello @Y-T-G, thank you for submitting a pull request to the ultralytics/ultralytics 🚀 repository! This is an automated response, and an Ultralytics engineer will review and assist with your submission soon. Meanwhile, please ensure the following checklist is complete to facilitate a smooth integration:

  • Define a Purpose: You've done a great job explaining the purpose of your enhancement to include imgsz with GFLOPs! If you haven't already, link any relevant issues for additional context.
  • Synchronize with Source: Make sure your PR is up-to-date with the main branch. If there are any updates, please sync your branch by clicking 'Update branch' or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Check that all Ultralytics Continuous Integration (CI) checks are passing. If any tests are failing, please take the necessary steps to resolve them.
  • Update Documentation: If there are changes in functionality, don't forget to update the relevant documentation pages to reflect these updates.
  • Add Tests: Verify that all related tests pass and consider including additional tests if your change introduces any new functionality.
  • Sign the CLA: Confirm you've signed our Contributor License Agreement by writing "I have read the CLA Document and I sign the CLA" in a new message if this is your first contribution.
  • Minimize Changes: Keep the changes to the necessary minimum. Focus on the enhancement's main purpose while avoiding extraneous modifications.

For detailed guidelines, please refer to our Contributing Guide. Feel free to reach out if you have any queries. Thank you for your valuable contribution! 🌟🚀

Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.12%. Comparing base (4f4cd62) to head (2f85e58).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16955      +/-   ##
==========================================
- Coverage   75.15%   75.12%   -0.04%     
==========================================
  Files         144      144              
  Lines       19278    19278              
==========================================
- Hits        14489    14483       -6     
- Misses       4789     4795       +6     
Flag Coverage Δ
Benchmarks 31.20% <0.00%> (-0.04%) ⬇️
GPU 36.72% <100.00%> (ø)
Tests 69.24% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Y-T-G
Copy link
Collaborator Author

Y-T-G commented Oct 16, 2024

On second thought, it might cause confusion in the sense that users might think the training is running at imgsz 640, just like how many of them think it's using YOLO11n due to the AMP check logs.

@Y-T-G
Copy link
Collaborator Author

Y-T-G commented Oct 16, 2024

Best thing would be to use the imgsz that the user is training at, but that information isn't available in that scope.

@glenn-jocher
Copy link
Member

glenn-jocher commented Oct 16, 2024

@Y-T-G yes I looked at this before, it would be nice to always show flops at the imgsz arg the user passed, but this required some changes to carry that information down to the lower level functions.

This would be the ideal solution though.

Copy link
Contributor

@Burhan-Q Burhan-Q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change, but what about updating to make it a bit more explicit? I think this would be a bit more clear.

@@ -324,7 +324,7 @@ def model_info(model, detailed=False, verbose=True, imgsz=640):

flops = get_flops(model, imgsz)
fused = " (fused)" if getattr(model, "is_fused", lambda: False)() else ""
fs = f", {flops:.1f} GFLOPs" if flops else ""
fs = f", {flops:.1f} GFLOPs (imgsz={imgsz})" if flops else ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- fs = f", {flops:.1f} GFLOPs (imgsz={imgsz})" if flops else ""
+ fs = f", {flops:.1f} GFLOPs (at imgsz = {imgsz})" if flops else ""

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of adding "at". I guess it makes it clearer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you should be able make it a bit shorter using this:

fs = f", {flops:.1f} GFLOPs (at {imgsz = })" if flops else ""

it's supported in Python 3.8

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.

@@ -324,7 +324,7 @@ def model_info(model, detailed=False, verbose=True, imgsz=640):

flops = get_flops(model, imgsz)
fused = " (fused)" if getattr(model, "is_fused", lambda: False)() else ""
fs = f", {flops:.1f} GFLOPs" if flops else ""
fs = f", {flops:.1f} GFLOPs (imgsz={imgsz})" if flops else ""
yaml_file = getattr(model, "yaml_file", "") or getattr(model, "yaml", {}).get("yaml_file", "")
model_name = Path(yaml_file).stem.replace("yolo", "YOLO") or "Model"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question here, if verbose is false, return None, this is a little bit weird, I think silence print is better

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think so?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because sometimes, we only want to get mode_info without print.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, makes sense

@Y-T-G Y-T-G linked an issue Oct 24, 2024 that may be closed by this pull request
1 task
Copy link

👋 Hello there! We wanted to let you know that we've decided to close this pull request due to inactivity. We appreciate the effort you put into contributing to our project, but unfortunately, not all contributions are suitable or aligned with our product roadmap.

We hope you understand our decision, and please don't let it discourage you from contributing to open source projects in the future. We value all of our community members and their contributions, and we encourage you to keep exploring new projects and ways to get involved.

For additional resources and information, please see the links below:

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

@github-actions github-actions bot added the Stale Stale and schedule for closing soon label May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale Stale and schedule for closing soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

为什么给yolo11输入图片尺寸不同,但是模型的GFLOPs却相同
5 participants