optimum
optimum copied to clipboard
Add support for ORTModelForObjectDetection
Feature request
Hi, I went through optimum's code base and could not find support for object detection models. Is there plan to add ORTModelForObjectDetection just like ORTModelForImageClassification exists? Would be great to have this feature.
Object detection task is also supported as part of transformers pipeline
feature so I guess it should be possible to support this as part of optimum?
Motivation
I want to leverage onnx support for YOLOS model
Your contribution
I would be happy to help in adding support for this feature if someone can guide me.
We are currently working on adding ONNX export features in optimum, and could add support to this architecture as well.
Sounds great, thanks @mht-sharma! Looking forward to have this available!
Hello @shivalikasingh95 , great suggestion! If you want to contribute to adding ORTModelForObjectDetection
, I suggest:
- Reading https://github.com/huggingface/optimum/blob/main/CONTRIBUTING.md
- Most of the work will be extending
modeling_ort.py
, you can take inspiration from example from https://github.com/huggingface/optimum/blob/6dc2cf23b962a2a57879f0ce71f933f49670dd12/optimum/onnxruntime/modeling_ort.py#L978-L1020 . Here one caveat is that models for object detection may have have different classes, for example we haveDetrObjectDetectionOutput
,OwlViTObjectDetectionOutput
,YolosObjectDetectionOutput
, etc. As far as I know, there is no map in transformers of a model to its corresponding output class. So a solution could be to output simply aModelOutput
. - Complete the
test_quantization.py
,test_modeling.py
,test_optimization.py
with tests for the new class - Optionally, add the new class in
trainer.py
andpipelines.py
for pipeline support - Ping me once you open a PR
Let us know if you are interested in contributing to this!
@fxmarty, apologies for the delay in my response. Last week was a bit tight. And sure I'd be happy to contribute to this. The points you have mentioned are very helpful and gives me enough to get started. However, I'm currently working on another PR for transformers library. It's a model contribution so it's taking some time. I can take up ORTModelForObjectDetection post finishing that. Hope that's not a problem?
Of course no worries! Don't hesitate to open a draft PR once you are on it if you need any help; if a team member wants to implement the class earlier let's follow on in this issue as well 🤗
Awesome thanks @fxmarty! I'll keep you posted regarding status on this. Will definitely open up a draft PR once I get started to get some guidance. And sure, in case any team member wants to take up this task, let me know here :)
Any news?