Created
March 31, 2020 10:03
-
-
Save Saafke/e8380cc925ece7cf283f2d7726eb49d9 to your computer and use it in GitHub Desktop.
Python code for upscaling an image via OpenCV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
from cv2 import dnn_superres | |
# Create an SR object | |
sr = dnn_superres.DnnSuperResImpl_create() | |
# Read image | |
image = cv2.imread('./input.png') | |
# Read the desired model | |
path = "EDSR_x3.pb" | |
sr.readModel(path) | |
# Set the desired model and scale to get correct pre- and post-processing | |
sr.setModel("edsr", 3) | |
# Upscale the image | |
result = sr.upsample(image) | |
# Save the image | |
cv2.imwrite("./upscaled.png", result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not importing dnn_superres from opencv-contrib-python== 4.5.4