mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-18 20:18:24 +06:00
Fix reduce-labels in BEIT Fast Image Processor (#38042)
* Fixed reduce-labels * Little doc fix * Change docstring
This commit is contained in:
parent
9f9020fed3
commit
7f1a97bae3
@ -150,6 +150,7 @@ If you're interested in submitting a resource to be included here, please feel f
|
|||||||
[[autodoc]] BeitImageProcessor
|
[[autodoc]] BeitImageProcessor
|
||||||
- preprocess
|
- preprocess
|
||||||
- post_process_semantic_segmentation
|
- post_process_semantic_segmentation
|
||||||
|
|
||||||
## BeitImageProcessorFast
|
## BeitImageProcessorFast
|
||||||
|
|
||||||
[[autodoc]] BeitImageProcessorFast
|
[[autodoc]] BeitImageProcessorFast
|
||||||
|
@ -105,6 +105,7 @@ BEiT の使用を開始するのに役立つ公式 Hugging Face およびコミ
|
|||||||
|
|
||||||
[[autodoc]] BeitImageProcessor
|
[[autodoc]] BeitImageProcessor
|
||||||
- preprocess
|
- preprocess
|
||||||
|
- post_process_semantic_segmentation
|
||||||
|
|
||||||
## BeitImageProcessorFast
|
## BeitImageProcessorFast
|
||||||
|
|
||||||
|
@ -137,12 +137,22 @@ class BeitImageProcessorFast(BaseImageProcessorFast):
|
|||||||
processed_images = torch.stack(processed_images, dim=0) if return_tensors else processed_images
|
processed_images = torch.stack(processed_images, dim=0) if return_tensors else processed_images
|
||||||
return 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(
|
def _preprocess_segmentation_maps(
|
||||||
self,
|
self,
|
||||||
segmentation_maps,
|
segmentation_maps,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
"""Preprocesses a single segmentation map."""
|
"""Preprocesses segmentation maps."""
|
||||||
processed_segmentation_maps = []
|
processed_segmentation_maps = []
|
||||||
for segmentation_map in segmentation_maps:
|
for segmentation_map in segmentation_maps:
|
||||||
segmentation_map = self._process_image(
|
segmentation_map = self._process_image(
|
||||||
@ -215,7 +225,7 @@ class BeitImageProcessorFast(BaseImageProcessorFast):
|
|||||||
kwargs.pop("default_to_square")
|
kwargs.pop("default_to_square")
|
||||||
kwargs.pop("data_format")
|
kwargs.pop("data_format")
|
||||||
|
|
||||||
images = self._preprocess(
|
images = self._preprocess_images(
|
||||||
images=images,
|
images=images,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user