Implement ObjectDetection support #205
Open
benjamintli wants to merge 4 commits intohuggingface:mainfrom
Open
Conversation
Author
|
@guangy10 @larryliu0820 sorry for the tag, but would either of you be able to take a look at my PR? Not sure if there's a process I should have been following here 😅 |
Collaborator
|
Optimum CI is in a rough way right now so Ill mostly just look at your new test |
Author
|
Hey @larryliu0820 @JacobSzwejbka would you be able to take a look at my revision? Thank you! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR is an attempt to implement support for ObjectDetection models in optimum ExecuTorch. This PR adds
ExecuTorchModelForObjectDetection,ObjectDetectionExportableModule, a task for object-detection, and a test for DETR type models.Notes
ObjectDetectionExportableModuletraces an object detection model, and storesnum_channels,image_size,get_label_idsandget_label_namesnum_channelsis not consistently defined in configs for the existing object detection models, so the ObjectDetectionExportableModule will try a few different config options, and if it can't resolve it it'll default to 3 (RGB), which I feel like is a sensible default. the priority goeskwargs defined num_channels -> config defined num_channels -> 3image_sizeis also not defined in configurations typically, as some models have dynamic sizes; there's not really a sensible default, since users would pick a size to use at inference/deployment time. So for this, the image size is passed in via the CLI and will only be used for object-detection modelsget_label_idsandget_label_namesare two flat lists that are used to construct id2label; for some reason executorch doesn't seem to support storing dicts as values in constant_methods (it gets flattened)ExecuTorchModelForObjectDetectionhas 3 attributes: num_channels, image_size, and id2label, which is a dict of class ids to labels.timmas a dev dependency for DETRTesting
This is my first PR in this repo, so I'm open to any feedback!