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

Function preprocess

examples/onnx/squeezenet.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((224, 224))
35 img = img.crop((0, 0, 224, 224))
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_label():

Callers 1

squeezenet.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected