(model_path, lowres_path="", output_path='.')
| 219 | |
| 220 | |
| 221 | def 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 | |
| 241 | def get_data(file_name): |
no test coverage detected
searching dependent graphs…