Fix reduce-labels in BEIT Fast Image Processor (#38042)

* Fixed reduce-labels

* Little doc fix

* Change docstring
This commit is contained in:
Mikhail Moskovchenko 2025-05-09 19:51:46 +04:00 committed by GitHub
parent 9f9020fed3
commit 7f1a97bae3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View File

@ -150,6 +150,7 @@ If you're interested in submitting a resource to be included here, please feel f
[[autodoc]] BeitImageProcessor
- preprocess
- post_process_semantic_segmentation
## BeitImageProcessorFast
[[autodoc]] BeitImageProcessorFast

View File

@ -105,6 +105,7 @@ BEiT の使用を開始するのに役立つ公式 Hugging Face およびコミ
[[autodoc]] BeitImageProcessor
- preprocess
- post_process_semantic_segmentation
## BeitImageProcessorFast

View File

@ -137,12 +137,22 @@ class BeitImageProcessorFast(BaseImageProcessorFast):
processed_images = torch.stack(processed_images, dim=0) if return_tensors else processed_images
return processed_images
def _preprocess_images(
self,
images,
**kwargs,
):
"""Preprocesses images."""
kwargs["do_reduce_labels"] = False
processed_images = self._preprocess(images=images, **kwargs)
return processed_images
def _preprocess_segmentation_maps(
self,
segmentation_maps,
**kwargs,
):
"""Preprocesses a single segmentation map."""
"""Preprocesses segmentation maps."""
processed_segmentation_maps = []
for segmentation_map in segmentation_maps:
segmentation_map = self._process_image(
@ -215,7 +225,7 @@ class BeitImageProcessorFast(BaseImageProcessorFast):
kwargs.pop("default_to_square")
kwargs.pop("data_format")
images = self._preprocess(
images = self._preprocess_images(
images=images,
**kwargs,
)