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

feature/add torchserve detectron2 #3355

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Mudassar-MLE
Copy link

@Mudassar-MLE Mudassar-MLE commented Nov 3, 2024

Add Detectron2 Support to TorchServe Object Detection Examples (#3344)

This pull request introduces support for Detectron2 models in TorchServe, addressing issue #3344. It includes a custom handler designed to ensure seamless deployment on both CPU and GPU environments, automatically managing device compatibility. Additionally, the example provides a requirements.txt file for dependencies and a detailed README to guide users in deploying pre-trained models from the Detectron2 Model Zoo as well as custom fine-tuned models. The updates are placed under examples/object_detector/detectron2 as suggested by the maintainers.

The contribution aims to simplify the deployment process for Detectron2 models in TorchServe, enhancing its usability for developers and making it a more commercially viable option for object detection tasks.

@Mudassar-MLE Mudassar-MLE marked this pull request as draft November 3, 2024 12:03

---

## Contributors
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this section


---

## Usage
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please take a look at other examples and show all the steps in this README. Anyone should be able to replicate the example looking at just the README.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the guidance! I’ve now updated the README file.

logger.info(f"Inference started for a batch of {len(model_input)}.")

outputs = []
for idx, image in enumerate(model_input):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can detectron2 process a batch of images? Can we send the batch instead of looping over each image

Copy link
Author

Choose a reason for hiding this comment

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

Yes, Detectron2 can process a batch of images, and we can send them.

List[str]: List of predictions.
"""
logger.info("Handling request...")
start_time = time.time()
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already have a utility to measure the time, please check this handler

@agunapal
Copy link
Collaborator

HI @Mudassar-MLE Thanks for the PR. Can you please add some context in the PR and write a short description

@Mudassar-MLE Mudassar-MLE requested a review from agunapal January 8, 2025 18:09
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