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

Function apply_inference_graph

examples/basics/export-model.py:140–152  ·  view source on GitHub ↗

Run inference from a different graph, which receives encoded images buffers.

(model_path)

Source from the content-addressed store, hash-verified

138
139
140def 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
155def apply_compact(graph_path):

Callers 1

export-model.pyFile · 0.85

Calls 5

PredictConfigClass · 0.85
SmartInitFunction · 0.85
InferenceOnlyModelClass · 0.85
OfflinePredictorClass · 0.85
readMethod · 0.80

Tested by

no test coverage detected