Run inference from a different graph, which receives encoded images buffers.
(model_path)
| 138 | |
| 139 | |
| 140 | def apply_inference_graph(model_path): |
| 141 | """Run inference from a different graph, which receives encoded images buffers. """ |
| 142 | pred_config = PredictConfig( |
| 143 | session_init=SmartInit(model_path), |
| 144 | model=InferenceOnlyModel(), |
| 145 | input_names=['input_img_bytes'], |
| 146 | output_names=['prediction_img_bytes']) |
| 147 | |
| 148 | pred = OfflinePredictor(pred_config) |
| 149 | buf = open('lena.png', 'rb').read() |
| 150 | prediction = pred([buf])[0] |
| 151 | with open('applied_inference_graph.png', 'wb') as f: |
| 152 | f.write(prediction[0]) |
| 153 | |
| 154 | |
| 155 | def apply_compact(graph_path): |
no test coverage detected