-
Notifications
You must be signed in to change notification settings - Fork 487
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
Add ONNX export support for DinoV2, Hiera, Maskformer, PVT, SigLIP, SwinV2, VitMAE, and VitMSN models #2001
Merged
Merged
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
62174bd
Add support for siglip models
xenova 3860ac3
cleanup
xenova 3e23538
remove submodule
xenova be9c707
Add ONNX export for DinoV2 models
xenova c4d6bc2
Use height and width from preprocessor
xenova cb8d362
formatting
xenova 94c3329
Remove attention mask from model input
xenova 9db1428
Merge branch 'main' into xenova-add-siglip
xenova 8d4b09e
Add ONNX export support for Hiera models
xenova b96bb61
Add ONNX export support for SwinV2
xenova 95336c0
Merge remote-tracking branch 'origin/add-dino' into add-hiera-onnx
xenova d4321b6
Merge remote-tracking branch 'origin/xenova-add-siglip' into add-hier…
xenova fe140c6
Upgrade Siglip to opset=14
xenova 09ae91a
Add VQA task
xenova 96afc91
Add ONNX export support for Maskformer
xenova 844aa66
Add ONNX export support for PVT
xenova de07c7a
Add ONNX export support for ViTMAE and ViTMSN
xenova 398d07a
Add siglip unit tests
xenova 86706d1
Add vit-mae unit tests
xenova 2fa69b4
Merge branch 'main' into add-hiera-onnx
xenova 8ad2e3a
Code formatting
xenova 55a19cb
Add maskformer to list of supported models
xenova fd15bd3
Formatting
xenova a47cd96
merge main in branch
echarlaix 7f0cb92
fix typo
echarlaix 7a2e94a
remove vit-mae masked-im task
echarlaix 01929b2
remove vit-msn masked-im task
echarlaix 3fa346c
fix output names for maskformer export
echarlaix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -209,7 +209,12 @@ class TasksManager: | |||
"feature-extraction": "AutoModel", | ||||
"fill-mask": "AutoModelForMaskedLM", | ||||
"image-classification": "AutoModelForImageClassification", | ||||
"image-segmentation": ("AutoModelForImageSegmentation", "AutoModelForSemanticSegmentation"), | ||||
"image-segmentation": ( | ||||
"AutoModelForImageSegmentation", | ||||
"AutoModelForSemanticSegmentation", | ||||
"AutoModelForInstanceSegmentation", | ||||
"AutoModelForUniversalSegmentation", | ||||
), | ||||
"image-to-image": "AutoModelForImageToImage", | ||||
"image-to-text": ("AutoModelForVision2Seq", "AutoModel"), | ||||
"mask-generation": "AutoModel", | ||||
|
@@ -224,6 +229,7 @@ class TasksManager: | |||
"text2text-generation": "AutoModelForSeq2SeqLM", | ||||
"text-classification": "AutoModelForSequenceClassification", | ||||
"token-classification": "AutoModelForTokenClassification", | ||||
"visual-question-answering": "AutoModelForVisualQuestionAnswering", | ||||
"zero-shot-image-classification": "AutoModelForZeroShotImageClassification", | ||||
"zero-shot-object-detection": "AutoModelForZeroShotObjectDetection", | ||||
} | ||||
|
@@ -307,6 +313,7 @@ class TasksManager: | |||
"vision2seq-lm": "image-to-text", | ||||
"zero-shot-classification": "text-classification", | ||||
"image-feature-extraction": "feature-extraction", | ||||
"pretraining": "feature-extraction", | ||||
# for backward compatibility and testing (where | ||||
# model task and model type are still the same) | ||||
"stable-diffusion": "text-to-image", | ||||
|
@@ -601,6 +608,11 @@ class TasksManager: | |||
"image-segmentation", | ||||
onnx="DetrOnnxConfig", | ||||
), | ||||
"dinov2": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"image-classification", | ||||
onnx="Dinov2OnnxConfig", | ||||
), | ||||
"distilbert": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"fill-mask", | ||||
|
@@ -732,6 +744,11 @@ class TasksManager: | |||
"feature-extraction", | ||||
onnx="GroupViTOnnxConfig", | ||||
), | ||||
"hiera": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"image-classification", | ||||
onnx="HieraOnnxConfig", | ||||
), | ||||
"hubert": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"automatic-speech-recognition", | ||||
|
@@ -813,6 +830,11 @@ class TasksManager: | |||
"question-answering", | ||||
onnx="MarkupLMOnnxConfig", | ||||
), | ||||
"maskformer": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"image-segmentation", | ||||
onnx="MaskformerOnnxConfig", | ||||
), | ||||
"mbart": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"feature-extraction-with-past", | ||||
|
@@ -1011,6 +1033,11 @@ class TasksManager: | |||
"image-classification", | ||||
onnx="PoolFormerOnnxConfig", | ||||
), | ||||
"pvt": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"image-classification", | ||||
onnx="PvtOnnxConfig", | ||||
), | ||||
"regnet": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"image-classification", | ||||
|
@@ -1070,6 +1097,23 @@ class TasksManager: | |||
"audio-classification", | ||||
onnx="SEWDOnnxConfig", | ||||
), | ||||
"siglip": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"zero-shot-image-classification", | ||||
onnx="SiglipOnnxConfig", | ||||
), | ||||
"siglip-text-model": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
onnx="SiglipTextOnnxConfig", | ||||
), | ||||
"siglip-text-with-projection": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
onnx="SiglipTextWithProjectionOnnxConfig", | ||||
), | ||||
"siglip-vision-model": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
onnx="SiglipVisionModelOnnxConfig", | ||||
), | ||||
"speech-to-text": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"feature-extraction-with-past", | ||||
|
@@ -1102,6 +1146,12 @@ class TasksManager: | |||
"masked-im", | ||||
onnx="SwinOnnxConfig", | ||||
), | ||||
"swinv2": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"image-classification", | ||||
"masked-im", | ||||
onnx="SwinV2OnnxConfig", | ||||
), | ||||
"swin2sr": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"image-to-image", | ||||
|
@@ -1148,7 +1198,21 @@ class TasksManager: | |||
onnx="VisionEncoderDecoderOnnxConfig", | ||||
), | ||||
"vit": supported_tasks_mapping( | ||||
"feature-extraction", "image-classification", "masked-im", onnx="ViTOnnxConfig" | ||||
"feature-extraction", | ||||
"image-classification", | ||||
"masked-im", | ||||
onnx="ViTOnnxConfig", | ||||
), | ||||
"vit-mae": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"masked-im", | ||||
onnx="VitMAEOnnxConfig", | ||||
), | ||||
"vit-msn": supported_tasks_mapping( | ||||
"feature-extraction", | ||||
"image-classification", | ||||
"masked-im", | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same I think can be removed :
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed in 01929b2 |
||||
onnx="VitMSNOnnxConfig", | ||||
), | ||||
"vits": supported_tasks_mapping( | ||||
"text-to-audio", | ||||
|
@@ -1232,6 +1296,10 @@ class TasksManager: | |||
"unet-2d-condition", | ||||
"vae-encoder", | ||||
"vae-decoder", | ||||
"clip-text-model", | ||||
"clip-text-with-projection", | ||||
"siglip-text-model", | ||||
"siglip-text-with-projection", | ||||
# redundant model types | ||||
"trocr", # same as vision-encoder-decoder | ||||
} | ||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
"image-feature-extraction"
(or"feature-extraction"
) should be enough https://huggingface.co/datasets/huggingface/transformers-metadata/blob/main/pipeline_tags.json#L1128if not the correct class needed to load the model can be added to
_CUSTOM_CLASSES
: for vit-mae I only seeAutoModel
orAutoModelForPreTraining
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed in 7a2e94a