Skip to content

Conversation

@simonreise
Copy link
Contributor

@simonreise simonreise commented May 9, 2025

What does this PR do?

When running BeitImageProcessorFast with do_reduce_labels=True, it not only reduces labels in segmentation map, but also applies reduce_label to the image itself

reduce_label should be applied only to segmentation maps

Test

import transformers
import torch


processor = transformers.BeitImageProcessorFast(
    do_resize=False, 
    do_center_crop=False, 
    do_rescale=False, 
    do_normalize=False, 
    do_convert_rgb=False,
)

image = torch.zeros([1, 3, 256, 256])

segmap = torch.zeros([1, 256, 256]) 

batch = processor.preprocess(
    images = image, 
    segmentation_maps = segmap, 
    return_tensors="pt", 
    do_reduce_labels=True,
)

pixel_values will be 255, should be 0.

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.

@yonigozlan

@github-actions github-actions bot marked this pull request as draft May 9, 2025 13:11
@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2025

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@simonreise simonreise marked this pull request as ready for review May 9, 2025 13:17
@github-actions github-actions bot requested review from stevhliu and yonigozlan May 9, 2025 13:17
@simonreise simonreise changed the title Fixed reduce-labels in BEIT Fast Image Processor Fix reduce-labels in BEIT Fast Image Processor May 9, 2025
Copy link
Member

@yonigozlan yonigozlan 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 catching that! Just a small nit on the docstring, otherwise LGTM!

@simonreise simonreise force-pushed the fp-beit-fix-reduce-labels branch from 43d904c to 4d5cb42 Compare May 9, 2025 15:30
@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.

@yonigozlan yonigozlan merged commit 7f1a97b into huggingface:main May 9, 2025
11 checks passed
@simonreise simonreise deleted the fp-beit-fix-reduce-labels branch May 9, 2025 15:53
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* Fixed reduce-labels

* Little doc fix

* Change docstring
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