Skip to content

Adds new CLI command for model info#16436

Closed
Burhan-Q wants to merge 85 commits intomainfrom
cli-info
Closed

Adds new CLI command for model info#16436
Burhan-Q wants to merge 85 commits intomainfrom
cli-info

Conversation

@Burhan-Q
Copy link
Contributor

@Burhan-Q Burhan-Q commented Sep 23, 2024

Idea is to allow for extracting/viewing information about a model from the CLI command. This could help to inspect the model information and metadata quickly without having to use the Python API directly.

Ex1 PyTorch + model basic info

yolo info yolov8s.pt
Ultralytics Model Info:
--------------------------------------------------------------------------------
Model File: yolov8s.pt
YOLOv8s summary: 225 layers, 11,166,560 parameters, 0 gradients, 28.8 GFLOPs

Ex 2 PyTorch model + metadata

yolo info yolov8n.pt meta=True
Ultralytics Model Info:
--------------------------------------------------------------------------------
Model File: yolov8s.pt
Date: 2022-12-30T08:15:10.989874
Version: 8.0.0.dev0
License: AGPL-3.0 License (https://ultralytics.com/license)
Docs: https://docs.ultralytics.com
Epoch: -1
Best_fitness: None
Classes: 80
--------------------------------------------------------------------------------
YOLOv8s summary: 225 layers, 11,166,560 parameters, 0 gradients, 28.8 GFLOPs

Ex 3 ONNX model + checking metadata

Ultralytics Model Info:
--------------------------------------------------------------------------------
Model File: yolov8m.onnx
License: AGPL-3.0 License (https://ultralytics.com/license)
Version: 8.2.70
Date: 2024-08-07T08:41:13.643800
Docs: https://docs.ultralytics.com
Classes: 80
--------------------------------------------------------------------------------

Ex 4 CoreML model + metadata + class list

yolo info yolov8n.mlpackage meta=True classes=True
Output

Ultralytics Model Info:
--------------------------------------------------------------------------------
Model File: yolov8n.mlpackage
Docs: https://docs.ultralytics.com
Date: 2024-09-23T05:46:48.748179
Classes: 
        0: person
        1: bicycle
        2: car
        3: motorcycle
        4: airplane
        5: bus
        6: train
        7: truck
        8: boat
        9: traffic light
        10: fire hydrant
        11: stop sign
        12: parking meter
        13: bench
        14: bird
        15: cat
        16: dog
        17: horse
        18: sheep
        19: cow
        20: elephant
        21: bear
        22: zebra
        23: giraffe
        24: backpack
        25: umbrella
        26: handbag
        27: tie
        28: suitcase
        29: frisbee
        30: skis
        31: snowboard
        32: sports ball
        33: kite
        34: baseball bat
        35: baseball glove
        36: skateboard
        37: surfboard
        38: tennis racket
        39: bottle
        40: wine glass
        41: cup
        42: fork
        43: knife
        44: spoon
        45: bowl
        46: banana
        47: apple
        48: sandwich
        49: orange
        50: broccoli
        51: carrot
        52: hot dog
        53: pizza
        54: donut
        55: cake
        56: chair
        57: couch
        58: potted plant
        59: bed
        60: dining table
        61: toilet
        62: tv
        63: laptop
        64: mouse
        65: remote
        66: keyboard
        67: cell phone
        68: microwave
        69: oven
        70: toaster
        71: sink
        72: refrigerator
        73: book
        74: clock
        75: vase
        76: scissors
        77: teddy bear
        78: hair drier
        79: toothbrush
--------------------------------------------------------------------------------

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improved the YOLO command line interface with a new command for viewing model details.

📊 Key Changes

  • Introduced yolo info command to display detailed model metadata and configuration.
  • Updated documentation with examples and usage of the new command.
  • Added tests to validate the yolo info command functionality.

🎯 Purpose & Impact

  • Enhanced Usability: Simplifies access to model details, helping users understand configurations and metadata directly from the terminal. 🛠️
  • Streamlined Workflow: Useful for scripting and automation by allowing model searches based on specific characteristics. 🔍
  • Improved Documentation: Provides clear guidance on using new features, aiding both beginners and advanced users. 📚

@Burhan-Q Burhan-Q added the enhancement New feature or request label Sep 23, 2024
@Burhan-Q Burhan-Q self-assigned this Sep 23, 2024
@codecov
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 92.10526% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.03%. Comparing base (e0f8eda) to head (0d85630).
Report is 665 commits behind head on main.

Files with missing lines Patch % Lines
ultralytics/cfg/__init__.py 92.10% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16436      +/-   ##
==========================================
- Coverage   78.59%   74.03%   -4.56%     
==========================================
  Files         128      128              
  Lines       17138    17175      +37     
==========================================
- Hits        13469    12715     -754     
- Misses       3669     4460     +791     
Flag Coverage Δ
Benchmarks 34.91% <5.26%> (-0.11%) ⬇️
GPU 38.39% <5.26%> (-2.71%) ⬇️
Tests 67.88% <92.10%> (-4.60%) ⬇️

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.

@inisis
Copy link
Contributor

inisis commented Sep 29, 2024

How about changing yolo info -> yolo inspect

@glenn-jocher
Copy link
Member

@inisis thank you for the suggestion! We'll consider it for future updates.

@inisis
Copy link
Contributor

inisis commented Sep 29, 2024

@glenn-jocher What about inspecting an onnx model, we can call onnxslim --inspect model.onnx or with an inscript call to see the details

@glenn-jocher
Copy link
Member

Thank you for the suggestion! We'll consider adding an inspection feature for ONNX models in future updates.

@inisis
Copy link
Contributor

inisis commented Oct 1, 2024

@glenn-jocher @Burhan-Q How about format summary like this

yolo info yolov8s.pt

pt

yolo info yolov8n.pt meta=True

pt_meta

yolo info yolov8n-obb.onnx meta=True

onnx

yolo info yolov8n.mlpackage meta=True classes=True

coreml

@glenn-jocher
Copy link
Member

Thank you for the suggestion! We'll consider enhancing the format summary for future updates.

@inisis
Copy link
Contributor

inisis commented Oct 2, 2024

@glenn-jocher we can also print the onnx model in details, I can submit a pr for it

onnx

@glenn-jocher
Copy link
Member

Thank you for the offer! Please feel free to submit a PR, and we'll review it.

@Burhan-Q
Copy link
Contributor Author

Burhan-Q commented Oct 2, 2024

@inisis I'm guessing (not 100% certain) that ONNX detail would be specific to the format. Currently, the implementation I have is agnostic to the file format and is primarily looking for the model metadata. I like the idea of having that kind of information shown, but it would need to work for all formats, which would be a massive PR (smaller + simpler is the way to go). Also, subjectively, the alignment for the OPs numbers is triggering me 😆

I'm still waiting on feedback from the Team if this idea is of any interest to merge into the code. I'm thinking we should see what the feedback looks like before we jump in too deep with the idea and stacking features; this is intended to be an MVP.

@inisis
Copy link
Contributor

inisis commented Oct 3, 2024

I have created a pr #16648

@glenn-jocher
Copy link
Member

Thank you for your contribution! We'll review your PR soon.

@glenn-jocher
Copy link
Member

@Burhan-Q changes look good, ready for review once the conflicts are resolved.

@Burhan-Q
Copy link
Contributor Author

@glenn-jocher I no longer have permissions to push to this branch.

@glenn-jocher
Copy link
Member

It seems like you may need to fork the repository and submit a new pull request with your changes. Let us know if you need further guidance!

@github-actions
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 Mar 12, 2025
@glenn-jocher glenn-jocher deleted the cli-info branch May 17, 2025 15:13
@glenn-jocher
Copy link
Member

@Burhan-Q closing as too many code changes here for this feature. Thank you for the effort though!

@glenn-jocher glenn-jocher removed the TODO High priority items label May 17, 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.

6 participants