MCPcopy
hub / github.com/fchollet/deep-learning-models / preprocess_input

Function preprocess_input

imagenet_utils.py:11–28  ·  view source on GitHub ↗
(x, dim_ordering='default')

Source from the content-addressed store, hash-verified

9
10
11def preprocess_input(x, dim_ordering='default'):
12 if dim_ordering == 'default':
13 dim_ordering = K.image_dim_ordering()
14 assert dim_ordering in {'tf', 'th'}
15
16 if dim_ordering == 'th':
17 x[:, 0, :, :] -= 103.939
18 x[:, 1, :, :] -= 116.779
19 x[:, 2, :, :] -= 123.68
20 # 'RGB'->'BGR'
21 x = x[:, ::-1, :, :]
22 else:
23 x[:, :, :, 0] -= 103.939
24 x[:, :, :, 1] -= 116.779
25 x[:, :, :, 2] -= 123.68
26 # 'RGB'->'BGR'
27 x = x[:, :, :, ::-1]
28 return x
29
30
31def decode_predictions(preds, top=5):

Callers 3

resnet50.pyFile · 0.90
vgg16.pyFile · 0.90
vgg19.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected