MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / process_image

Method process_image

NLP/UNIMO-2/src/utils/image_utils.py:103–112  ·  view source on GitHub ↗

Given an image, process it and return the array.

(self, image_path)

Source from the content-addressed store, hash-verified

101 return x
102
103 def process_image(self, image_path):
104 """Given an image, process it and return the array."""
105 # Load the image.
106 image = self._load_img(image_path)
107 if image is None:
108 return None
109 img_arr = self._img_to_array(image)
110 x = (img_arr / 255.).astype('float32') #
111 x = (x - self.mean) / self.std # normalize images
112 return x
113
114 def random_crop(self, img, target_size, p=0.5):
115 """random crop image"""

Callers 2

process_imageFunction · 0.95
test_img_readerFunction · 0.95

Calls 2

_load_imgMethod · 0.95
_img_to_arrayMethod · 0.95

Tested by 1

test_img_readerFunction · 0.76