Skip to content

Commit 9c3c810

Browse files
committed
Add ONNX export for owlv2
1 parent 9201bd4 commit 9c3c810

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

optimum/exporters/onnx/model_configs.py

+4
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,10 @@ def outputs(self) -> Dict[str, Dict[int, str]]:
10851085
return outputs
10861086

10871087

1088+
class OwlV2OnnxConfig(OwlViTOnnxConfig):
1089+
DEFAULT_ONNX_OPSET = 14
1090+
1091+
10881092
class LayoutLMOnnxConfig(TextAndVisionOnnxConfig):
10891093
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig.with_args(
10901094
allow_new=True,

optimum/exporters/tasks.py

+5
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,11 @@ class TasksManager:
808808
"token-classification",
809809
onnx="NystromformerOnnxConfig",
810810
),
811+
"owlv2": supported_tasks_mapping(
812+
"feature-extraction",
813+
"zero-shot-object-detection",
814+
onnx="OwlV2OnnxConfig",
815+
),
811816
"owlvit": supported_tasks_mapping(
812817
"feature-extraction",
813818
"zero-shot-object-detection",

optimum/utils/normalized_config.py

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class NormalizedConfigManager:
199199
'levit',
200200
'mobilebert',
201201
'mobilevit',
202+
'owlv2',
202203
'owlvit',
203204
'perceiver',
204205
'roformer',

tests/exporters/exporters_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"mt5": "lewtun/tiny-random-mt5",
122122
"nystromformer": "hf-internal-testing/tiny-random-NystromformerModel",
123123
"opt": "hf-internal-testing/tiny-random-OPTModel",
124+
"owlv2": "hf-internal-testing/tiny-random-Owlv2Model",
124125
"owlvit": "hf-tiny-model-private/tiny-random-OwlViTModel",
125126
"pegasus": "hf-internal-testing/tiny-random-PegasusModel",
126127
"perceiver": {
@@ -241,6 +242,7 @@
241242
"mpt": "mosaicml/mpt-7b",
242243
"mt5": "lewtun/tiny-random-mt5", # Not using google/mt5-small because it takes too much time for testing.
243244
"nystromformer": "hf-internal-testing/tiny-random-NystromformerModel",
245+
"owlv2": "google/owlv2-base-patch16",
244246
"owlvit": "google/owlvit-base-patch32",
245247
"perceiver": "hf-internal-testing/tiny-random-PerceiverModel", # Not using deepmind/language-perceiver because it takes too much time for testing.
246248
# "rembert": "google/rembert",

0 commit comments

Comments
 (0)