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

Function run

examples/HED/hed.py:270–291  ·  view source on GitHub ↗
(model_path, image_path, output)

Source from the content-addressed store, hash-verified

268
269
270def run(model_path, image_path, output):
271 pred_config = PredictConfig(
272 model=Model(),
273 session_init=SmartInit(model_path),
274 input_names=['image'],
275 output_names=['output' + str(k) for k in range(1, 7)])
276 predictor = OfflinePredictor(pred_config)
277 im = cv2.imread(image_path)
278 assert im is not None
279 im = cv2.resize(
280 im, (im.shape[1] // 16 * 16, im.shape[0] // 16 * 16)
281 )[None, :, :, :].astype('float32')
282 outputs = predictor(im)
283 if output is None:
284 for k in range(6):
285 pred = outputs[k][0]
286 cv2.imwrite("out{}.png".format(
287 '-fused' if k == 5 else str(k + 1)), pred * 255)
288 logger.info("Results saved to out*.png")
289 else:
290 pred = outputs[5][0]
291 cv2.imwrite(output, pred * 255)
292
293
294if __name__ == '__main__':

Callers 2

hed.pyFile · 0.70
create_sessionMethod · 0.50

Calls 5

PredictConfigClass · 0.85
SmartInitFunction · 0.85
OfflinePredictorClass · 0.85
formatMethod · 0.80
ModelClass · 0.70

Tested by

no test coverage detected