Skip to content

Commit f15b95e

Browse files
Allow LayoutLMV3Processor to accept rescale_factor (#42305)
* Allow LayoutLMV3Processor to accept rescale_factor * Allow LayoutLMV3Processor to accept rescale_factor * Make rescale_factor official
1 parent 73d5c2d commit f15b95e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/transformers/models/layoutlmv3/image_processing_layoutlmv3.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def __init__(
171171
size: Optional[dict[str, int]] = None,
172172
resample: PILImageResampling = PILImageResampling.BILINEAR,
173173
do_rescale: bool = True,
174-
rescale_value: float = 1 / 255,
174+
rescale_factor: float = 1 / 255,
175175
do_normalize: bool = True,
176176
image_mean: Optional[Union[float, Iterable[float]]] = None,
177177
image_std: Optional[Union[float, Iterable[float]]] = None,
@@ -188,7 +188,9 @@ def __init__(
188188
self.size = size
189189
self.resample = resample
190190
self.do_rescale = do_rescale
191-
self.rescale_factor = rescale_value
191+
# The standard name is rescale_factor, but this processor accepted rescale_value for a long time,
192+
# so allow it as a kwarg for backward compatibility
193+
self.rescale_factor = kwargs.get("rescale_value", rescale_factor)
192194
self.do_normalize = do_normalize
193195
self.image_mean = image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
194196
self.image_std = image_std if image_std is not None else IMAGENET_STANDARD_STD

0 commit comments

Comments
 (0)