MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / run_test

Function run_test

examples/CaffeModels/load-alexnet.py:39–57  ·  view source on GitHub ↗
(path, input)

Source from the content-addressed store, hash-verified

37
38
39def run_test(path, input):
40 predictor = OfflinePredictor(PredictConfig(
41 input_signature=[tf.TensorSpec((None, 227, 227, 3), tf.float32, 'input')],
42 tower_func=tower_func,
43 session_init=SmartInit(path),
44 input_names=['input'],
45 output_names=['prob']
46 ))
47
48 im = cv2.imread(input)
49 assert im is not None, input
50 im = cv2.resize(im, (227, 227))[None, :, :, ::-1].astype('float32') - 110
51 outputs = predictor(im)[0]
52 prob = outputs[0]
53 ret = prob.argsort()[-10:][::-1]
54 print("Top10 predictions:", ret)
55
56 meta = ILSVRCMeta().get_synset_words_1000()
57 print("Top10 class names:", [meta[k] for k in ret])
58
59
60if __name__ == '__main__':

Callers 1

load-alexnet.pyFile · 0.70

Calls 5

ILSVRCMetaClass · 0.90
OfflinePredictorClass · 0.85
PredictConfigClass · 0.85
SmartInitFunction · 0.85
get_synset_words_1000Method · 0.80

Tested by

no test coverage detected