Skip to content
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

Optionally preprocess segmentation maps for MobileViT #28420

Merged
merged 7 commits into from
Jan 11, 2024
Merged

Optionally preprocess segmentation maps for MobileViT #28420

merged 7 commits into from
Jan 11, 2024

Conversation

harisankar95
Copy link
Contributor

@harisankar95 harisankar95 commented Jan 9, 2024

What does this PR do?

  • Preprocessor can now accept segmentations maps as well and performs augmentations inline to input images.
  • Tests added for preprocessing segmentation masks.

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@harisankar95
Copy link
Contributor Author

@amyeroberts Can you please review the PR? MobileViT image preprocessor is updated to accept segmentation maps inline to other preprocessors for segmentation models like that of Segformer.

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

Overall looks good - just some general comments about the structure. Could you add some tests to make sure the maps are process as expected?

@@ -58,7 +58,7 @@


MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST = [
"apple/mobilevitv2-1.0-imagenet1k-256"
"apple/mobilevitv2-1.0-imagenet1k-256" "apple/mobilevitv2-1.0-voc-deeplabv3"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shouldn't be changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed it in 1669db1

@@ -306,6 +321,48 @@ def preprocess(
]

data = {"pixel_values": images}

if segmentation_maps is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add two new methods to keep in line with other models e.g. SAM here:

  • preprocess_image
  • preprocess_mask

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added additional methods to preprocess images and masks seperately in 877b81a

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this and the tests - looks great!

@harisankar95
Copy link
Contributor Author

I have corrected the error in the tests_torch. I will wait for the #28432 to be merged to fix the remaining CI tests

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding and iterating on this!

Just a small nit about keeping the same checkpoints in the doc example. Otherwise LGTM!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@amyeroberts amyeroberts merged commit d560637 into huggingface:main Jan 11, 2024
18 checks passed
staghado pushed a commit to staghado/transformers that referenced this pull request Jan 15, 2024
)

* optionally preprocess segmentation maps for mobilevit

* changed pretrained model name to that of segmentation model

* removed voc-deeplabv3 from model archive list

* added preprocess_image and preprocess_mask methods for processing images and segmentation masks respectively

* added tests for segmentation masks based on segformer feature extractor

* use crop_size instead of size

* reverting to initial model
MadElf1337 pushed a commit to MadElf1337/transformers that referenced this pull request Jan 15, 2024
)

* optionally preprocess segmentation maps for mobilevit

* changed pretrained model name to that of segmentation model

* removed voc-deeplabv3 from model archive list

* added preprocess_image and preprocess_mask methods for processing images and segmentation masks respectively

* added tests for segmentation masks based on segformer feature extractor

* use crop_size instead of size

* reverting to initial model
wgifford pushed a commit to wgifford/transformers that referenced this pull request Jan 21, 2024
)

* optionally preprocess segmentation maps for mobilevit

* changed pretrained model name to that of segmentation model

* removed voc-deeplabv3 from model archive list

* added preprocess_image and preprocess_mask methods for processing images and segmentation masks respectively

* added tests for segmentation masks based on segformer feature extractor

* use crop_size instead of size

* reverting to initial model
AjayP13 pushed a commit to AjayP13/transformers that referenced this pull request Jan 22, 2024
)

* optionally preprocess segmentation maps for mobilevit

* changed pretrained model name to that of segmentation model

* removed voc-deeplabv3 from model archive list

* added preprocess_image and preprocess_mask methods for processing images and segmentation masks respectively

* added tests for segmentation masks based on segformer feature extractor

* use crop_size instead of size

* reverting to initial model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants