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

Deploying yolov5 to TorchServe (GPU compatible) #1681

Closed
louisoutin opened this issue Dec 13, 2020 · 8 comments
Closed

Deploying yolov5 to TorchServe (GPU compatible) #1681

louisoutin opened this issue Dec 13, 2020 · 8 comments
Labels
enhancement New feature or request Stale

Comments

@louisoutin
Copy link

louisoutin commented Dec 13, 2020

🚀 Feature

  • Enable yolov5 deployment to torchserve on docker (GPU compatible).
  • Use a fixed batch_size (fill with 0 for fast inference if the batch is not full)

Motivation

I wanted to use YOLOv5 for my personal projects, using a GPU with fixed batch inference (multiple videos in concurrences),
and TorchServe seemed to be the best option. For this reason, I wanted to share this with the community, as I had some issues in settings things up (especially the handler file).

Pitch

Just sharing things :)

You can check this feature on this github repository:
https://github.com/louisoutin/yolov5_torchserve

Any feedbacks are welcome, thanks!

@louisoutin louisoutin added the enhancement New feature or request label Dec 13, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Dec 13, 2020

Hello @louisoutin, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

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 training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

@louisoutin awesome! Thank you for your contributions. I've not used TorchServe in the past, but I know we have had a request for a tutorial from other users. Can you explain a bit about the typical use-case here? How do you send images to the server and get results back? Thanks!

@louisoutin
Copy link
Author

louisoutin commented Dec 13, 2020

Hey, thanks @glenn-jocher !

I just updated the Readme with a "Getting predictions" part. But basically here it's how it's done:

Once the dockerimage is running, you can send POST requests to: localhost:8080/predictions/my_model (with my_model being the name of your model).

The handler in this project expect the inputs images to be sent via a Multipart form with a "key/value" form having in the keys the strings "img"+[index] and in the values, the bytes of each images.

Example:

For a batch_size of 5, we would have the following in our Multipart form request:

"img1": [bytes_of_the_1st_image],
"img2": [bytes_of_the_2st_image],
"img3": [bytes_of_the_3st_image],
"img4": [bytes_of_the_4st_image],
"img5": [bytes_of_the_5st_image],

The returned json of the request contain a single list. Each i-th element of this list represent the i-th image detection results (represented by: (x1, y1, x2, y2, conf, cls))

Note that if there is less input images than the batch size, the rest of the inference batch will be padded with zeros inputs.

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Jan 13, 2021
@jdongca2003
Copy link

You can find my scripts for YoloV5 torchServe setup https://github.com/jdongca2003/Yolov5_torchserve

@github-actions github-actions bot removed the Stale label Jan 17, 2021
@github-actions
Copy link
Contributor

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.

@khelkun
Copy link

khelkun commented Feb 24, 2023

Another YOLOv5.0 Release v7.0 deploy: https://github.com/ben-omji/serve_yolov5

@glenn-jocher
Copy link
Member

@khelkun thank you for sharing these repositories! It's great to see the YOLOv5 community actively contributing to different deployment options. The effort to make YOLOv5 accessible for various platforms is truly appreciated. 🙌 If there's anything specific you'd like assistance with, feel free to ask!

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
Projects
None yet
Development

No branches or pull requests

4 participants