(model_path, img_file)
| 95 | |
| 96 | |
| 97 | def run_test(model_path, img_file): |
| 98 | predict_func = OfflinePredictor(PredictConfig( |
| 99 | input_signature=[tf.TensorSpec((None, 368, 368, 3), tf.float32, 'input')], |
| 100 | tower_func=CPM, |
| 101 | session_init=SmartInit(model_path), |
| 102 | input_names=['input'], |
| 103 | output_names=['resized_map'] |
| 104 | )) |
| 105 | |
| 106 | im = cv2.imread(img_file, cv2.IMREAD_COLOR).astype('float32') |
| 107 | im = cv2.resize(im, (368, 368)) |
| 108 | out = predict_func(im[None, :, :, :])[0][0] |
| 109 | hm = out[:, :, :14].sum(axis=2) |
| 110 | viz = colorize(im, hm) |
| 111 | cv2.imwrite("output.jpg", viz) |
| 112 | |
| 113 | |
| 114 | if __name__ == '__main__': |
no test coverage detected