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

Function apply

examples/SuperResolution/enet-pat.py:221–238  ·  view source on GitHub ↗
(model_path, lowres_path="", output_path='.')

Source from the content-addressed store, hash-verified

219
220
221def apply(model_path, lowres_path="", output_path='.'):
222 assert os.path.isfile(lowres_path)
223 assert os.path.isdir(output_path)
224 lr = cv2.imread(lowres_path).astype(np.float32)
225 baseline = cv2.resize(lr, (0, 0), fx=4, fy=4, interpolation=cv2.INTER_CUBIC)
226 LR_SIZE_H, LR_SIZE_W = lr.shape[:2]
227
228 predict_func = OfflinePredictor(PredictConfig(
229 model=Model(LR_SIZE_H, LR_SIZE_W),
230 session_init=SmartInit(model_path),
231 input_names=['Ilr'],
232 output_names=['prediction']))
233
234 pred = predict_func(lr[None, ...])
235 p = np.clip(pred[0][0, ...], 0, 255)
236
237 cv2.imwrite(os.path.join(output_path, "predition.png"), p)
238 cv2.imwrite(os.path.join(output_path, "baseline.png"), baseline)
239
240
241def get_data(file_name):

Callers 1

enet-pat.pyFile · 0.70

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…