optimum icon indicating copy to clipboard operation
optimum copied to clipboard

Add support for ORTModelForObjectDetection

Open shivalikasingh95 opened this issue 2 years ago • 7 comments

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.

shivalikasingh95 avatar Oct 31 '22 19:10 shivalikasingh95

We are currently working on adding ONNX export features in optimum, and could add support to this architecture as well.

mht-sharma avatar Nov 01 '22 10:11 mht-sharma

Sounds great, thanks @mht-sharma! Looking forward to have this available!

shivalikasingh95 avatar Nov 01 '22 21:11 shivalikasingh95

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 have DetrObjectDetectionOutput, 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 a ModelOutput.
  • 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 and pipelines.py for pipeline support
  • Ping me once you open a PR

Let us know if you are interested in contributing to this!

fxmarty avatar Nov 02 '22 12:11 fxmarty

@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?

shivalikasingh95 avatar Nov 08 '22 18:11 shivalikasingh95

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 🤗

fxmarty avatar Nov 08 '22 21:11 fxmarty

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 :)

shivalikasingh95 avatar Nov 09 '22 12:11 shivalikasingh95

Any news?

failable avatar Jan 30 '24 04:01 failable