Skip to content
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

Enable extending the CLI with custom architectures #8298

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

Conversation

deanmark
Copy link
Contributor

@deanmark deanmark commented Feb 19, 2024

Enable extending the CLI with custom architectures. Allows extending the CLI, with the Ultralytics code as an external dependency. Example repo using this functionality here.

Key Changes

  • Added arch param to CLI entrypoint for external architecture injection.
  • Model initialization in entrypoint function is more generic.

Purpose & Impact

  • Easily extend Ultralytics codebase: Allows extending the Ultralytics code and CLI, with Ultralytics as an external dependency.
  • Advantages for 3rd party users: Using Ultralytics as an external dependency affords the following advantages -
    • Reduced code clutter
    • Changes are more visible
    • Easily update the base Ultralytics version

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Refined model initialization and architecture inference in Ultralytics library.

📊 Key Changes

  • 🧠 Introduced guess_architecture function to infer model architecture based on the file name.
  • 🛠 Created init_model function to initialize models with appropriate architecture and forwarded only the valid parameters from kwargs.
  • ✂️ Simplified entrypoint code by using the new init_model function instead of repeating architecture inference logic.

🎯 Purpose & Impact

  • 🎭 Model initialization process is more elegant and less error-prone, making it user-friendly.
  • 📘 Users can easily interact with different architectures without in-depth knowledge of the implementation details.
  • 🔗 Enhances maintainability by centralizing model initialization, which could encourage further expansions and features in the future.

Copy link

github-actions bot commented Feb 19, 2024

CLA Assistant Lite bot All Contributors have signed the CLA. ✅

@deanmark
Copy link
Contributor Author

I have read the CLA Document and I sign the CLA

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

👋 Hello @deanmark, thank you for submitting an Ultralytics YOLOv8 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with ultralytics/ultralytics main branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • ✅ Verify all YOLOv8 Continuous Integration (CI) checks are passing.
  • ✅ Update YOLOv8 Docs for any new or updated features.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

See our Contributing Guide for details and let us know if you have any questions!

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: Patch coverage is 90.47619% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 76.01%. Comparing base (d608565) to head (62bc1ef).

❗ Current head 62bc1ef differs from pull request most recent head 691d038. Consider uploading reports for the commit 691d038 to get more accurate results

Files Patch % Lines
ultralytics/cfg/__init__.py 90.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8298      +/-   ##
==========================================
+ Coverage   75.99%   76.01%   +0.01%     
==========================================
  Files         121      121              
  Lines       15332    15340       +8     
==========================================
+ Hits        11652    11660       +8     
  Misses       3680     3680              
Flag Coverage Δ
Benchmarks 36.05% <71.42%> (+0.03%) ⬆️
GPU 37.94% <19.04%> (-0.01%) ⬇️
Tests 71.31% <90.47%> (+0.01%) ⬆️

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.

@deanmark
Copy link
Contributor Author

@glenn-jocher
What do you think of the PR? I think it would be really nice to allow 3rd party developers to extend the CLI functionality, without having to change the original source code. Example repo showing how this can be performed here.

@glenn-jocher
Copy link
Member

Hello @deanmark! 👋

Thank you for the PR and the suggestion to enhance the CLI functionality. It's great to see community members actively looking to improve and extend the capabilities of the Ultralytics ecosystem. The idea of allowing third-party developers to extend the CLI without modifying the original source code is indeed intriguing and could open up new possibilities for customization and innovation.

We'll review the example repo and consider how this approach aligns with our goals for modularity and ease of use. Your contribution is much appreciated, and we're always excited to explore ways to make our tools more powerful and accessible for developers like you.

Keep an eye on the PR for further updates and discussions! 🚀

@Burhan-Q Burhan-Q added the enhancement New feature or request label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants