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

Function process_image

CV/webvision2018/reader.py:98–116  ·  view source on GitHub ↗

process_image

(sample, mode, color_jitter, rotate,
        crop_size=224, mean=None, std=None)

Source from the content-addressed store, hash-verified

96 return img
97
98def process_image(sample, mode, color_jitter, rotate,
99 crop_size=224, mean=None, std=None):
100 """ process_image """
101
102 mean = [0.485, 0.456, 0.406] if mean is None else mean
103 std = [0.229, 0.224, 0.225] if std is None else std
104
105
106 img_path = sample[0]
107 img = cv2.imread(img_path)
108 img = cv2.resize(img, (crop_size, crop_size))
109
110 img = img[:, :, ::-1].astype('float32').transpose((2, 0, 1)) / 255
111 img_mean = np.array(mean).reshape((3, 1, 1))
112 img_std = np.array(std).reshape((3, 1, 1))
113 img -= img_mean
114 img /= img_std
115
116 return (img, )
117
118def image_mapper(**kwargs):
119 """ image_mapper """

Callers

nothing calls this directly

Calls 2

resizeMethod · 0.80
transposeMethod · 0.45

Tested by

no test coverage detected