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

Allow multiple-model serving from Flask REST API #8973

Merged
merged 4 commits into from
Aug 15, 2022

Conversation

mpromonet
Copy link
Contributor

@mpromonet mpromonet commented Aug 15, 2022

Hi,

This is a small modification to allow to serve multiple models with the flask rest api.

Best Regards,
Michel.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhancement of the YOLOv5 Flask REST API to support multiple models simultaneously.

📊 Key Changes

  • The REST API now allows specifying which model to use in the request URL.
  • The server can load multiple models at startup based on command line arguments.
  • The prediction route (predict) dynamically selects the model based on the URL.
  • The hardcoded single model setup has been replaced with a flexible models dictionary.

🎯 Purpose & Impact

  • Flexibility: Users can now interact with different YOLOv5 models in a single API instance, which is useful for comparing results or if different use cases require different models.
  • Convenience: By allowing multiple models, users can avoid running separate instances for each model, saving resources and simplifying the interaction process.
  • Customizability: The update adds the ability to specify the desired models at server startup, giving users control over which models are loaded, and adjusting for performance or resource allocation as needed.

Copy link
Contributor

@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 @mpromonet, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with upstream/master. If your PR is behind upstream/master an automatic GitHub Actions merge may be attempted by writing /rebase in a new comment, or by running the following code, replacing 'feature' with the name of your local branch:
git remote add upstream https://github.com/ultralytics/yolov5.git
git fetch upstream
# git checkout feature  # <--- replace 'feature' with local branch name
git merge upstream/master
git push -u origin -f
  • ✅ Verify all Continuous Integration (CI) checks are passing.
  • ✅ 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

@mpromonet
Copy link
Contributor Author

mpromonet commented Aug 15, 2022

Hi @glenn-jocher ,

Thanks for cleanup, better your way.

Best Regards,
Michel.

@mpromonet mpromonet removed their assignment Aug 15, 2022
@glenn-jocher glenn-jocher changed the title allow to serve multiple models using flask restapi Allow multiple-model serving from Flask REST API Aug 15, 2022
@glenn-jocher glenn-jocher merged commit 4d05472 into ultralytics:master Aug 15, 2022
@glenn-jocher
Copy link
Member

@mpromonet PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐

@glenn-jocher
Copy link
Member

glenn-jocher commented Aug 15, 2022

@mpromonet yes by passing skip_validation=True to torch.hub.load() we bypass the need for fix #7210

ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* allow to serve multiple models using flask restapi

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Cleanup

* Update restapi.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants