Skip to content

Commit

Permalink
Add ONNX export for owlv2 (#1689)
Browse files Browse the repository at this point in the history
* Add ONNX export for owlv2

* Remove opset=14 requirement
  • Loading branch information
xenova authored Feb 29, 2024
1 parent 64f795d commit 8748081
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,10 @@ def outputs(self) -> Dict[str, Dict[int, str]]:
return outputs


class OwlV2OnnxConfig(OwlViTOnnxConfig):
pass


class LayoutLMOnnxConfig(TextAndVisionOnnxConfig):
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig.with_args(
allow_new=True,
Expand Down
5 changes: 5 additions & 0 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,11 @@ class TasksManager:
"token-classification",
onnx="NystromformerOnnxConfig",
),
"owlv2": supported_tasks_mapping(
"feature-extraction",
"zero-shot-object-detection",
onnx="OwlV2OnnxConfig",
),
"owlvit": supported_tasks_mapping(
"feature-extraction",
"zero-shot-object-detection",
Expand Down
1 change: 1 addition & 0 deletions optimum/utils/normalized_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class NormalizedConfigManager:
'levit',
'mobilebert',
'mobilevit',
'owlv2',
'owlvit',
'perceiver',
'roformer',
Expand Down
2 changes: 2 additions & 0 deletions tests/exporters/exporters_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"mt5": "lewtun/tiny-random-mt5",
"nystromformer": "hf-internal-testing/tiny-random-NystromformerModel",
"opt": "hf-internal-testing/tiny-random-OPTModel",
"owlv2": "hf-internal-testing/tiny-random-Owlv2Model",
"owlvit": "hf-tiny-model-private/tiny-random-OwlViTModel",
"pegasus": "hf-internal-testing/tiny-random-PegasusModel",
"perceiver": {
Expand Down Expand Up @@ -243,6 +244,7 @@
"mpt": "mosaicml/mpt-7b",
"mt5": "lewtun/tiny-random-mt5", # Not using google/mt5-small because it takes too much time for testing.
"nystromformer": "hf-internal-testing/tiny-random-NystromformerModel",
"owlv2": "google/owlv2-base-patch16",
"owlvit": "google/owlvit-base-patch32",
"perceiver": "hf-internal-testing/tiny-random-PerceiverModel", # Not using deepmind/language-perceiver because it takes too much time for testing.
# "rembert": "google/rembert",
Expand Down

0 comments on commit 8748081

Please sign in to comment.