(x, dim_ordering='default')
| 9 | |
| 10 | |
| 11 | def 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 | |
| 31 | def decode_predictions(preds, top=5): |
no outgoing calls
no test coverage detected