Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/transformers/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def convert_rgb(self, image):

return image.convert("RGB")

def rescale(self, image: np.ndarray, scale: Union[float, int]) -> np.ndarray:
def rescale_image(self, image: np.ndarray, scale: Union[float, int]) -> np.ndarray:
"""
Rescale a numpy image by scale amount
"""
Expand Down Expand Up @@ -163,7 +163,7 @@ def to_numpy_array(self, image, rescale=None, channel_first=True):
rescale = isinstance(image.flat[0], np.integer) if rescale is None else rescale

if rescale:
image = self.rescale(image.astype(np.float32), 1 / 255.0)
image = self.rescale_image(image.astype(np.float32), 1 / 255.0)

if channel_first and image.ndim == 3:
image = image.transpose(2, 0, 1)
Expand Down Expand Up @@ -214,9 +214,9 @@ def normalize(self, image, mean, std, rescale=False):
# type it may need rescaling.
elif rescale:
if isinstance(image, np.ndarray):
image = self.rescale(image.astype(np.float32), 1 / 255.0)
image = self.rescale_image(image.astype(np.float32), 1 / 255.0)
elif is_torch_tensor(image):
image = self.rescale(image.float(), 1 / 255.0)
image = self.rescale_image(image.float(), 1 / 255.0)

if isinstance(image, np.ndarray):
if not isinstance(mean, np.ndarray):
Expand Down