MCPcopy Create free account
hub / github.com/apache/singa / preprocess

Function preprocess

examples/onnx/resnet18.py:33–43  ·  view source on GitHub ↗
(img)

Source from the content-addressed store, hash-verified

31
32
33def preprocess(img):
34 img = img.resize((256, 256))
35 img = img.crop((16, 16, 240, 240))
36 img = np.array(img).astype(np.float32) / 255.
37 img = np.rollaxis(img, 2, 0)
38 for channel, mean, std in zip(range(3), [0.485, 0.456, 0.406],
39 [0.229, 0.224, 0.225]):
40 img[channel, :, :] -= mean
41 img[channel, :, :] /= std
42 img = np.expand_dims(img, axis=0)
43 return img
44
45
46def get_image_labe():

Callers 1

resnet18.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected