Upscale Image via CNN

by. Jongwon Lee | 178 Views (102 Uniq Views) | about 1 year ago
#CNN #OpenCV #ImageProcessing #Python #DeepLearning #AI
A class to upscale images via convolutional neural networks.
import cv2 
#import a pretrained model
sr = cv2.dnn_superres.DnnSuperResImpl_create() sr.readModel('models/EDSR_x3.pb') 
sr.setModel('edsr', 3)
#load image
img = cv2.imread('imgs/06.jpg')
result = sr.upsample(img)
#convert the input image to match the size of result
resized_img = cv2.resize(img, dsize=None, fx=3, fy=3) 

cv2.imshow('img', img)
cv2.imshow('resized_img', resized_img)
cv2.imshow('result', result)
cv2.waitKey(0) 

pip install opencv-contrib-python
or
pip install opencv-contrib-python --upgrade
Related Article:
EDSR(enhanced deep super-resolution network)
https://arxiv.org/pdf/1707.02921.pdf (2017)
Download model from:
https://github.com/Saafke/EDSR_Tensorflow/tree/master/models