Hi, this is the first time I’ve used open CV, so I’m sure it’s something I’ve done wrong. I’m getting the below error, and for some reason there’s mention of a D:/ drive, which I don’t have. It does generate the upscaled image, but it’s very blurry, so I’m guessing it’s not working properly.
PS E:\programming\opencv\tests>
result = sr.upsample(image)
= 0 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'
PS E:\programming\opencv\tests> e:; cd 'e:\programming\opencv\tests'; & 'C:\Users\3diWorkstation\AppData\Local\Programs\Python\Python39\python.exe' 'c:\Users\3diWorkstation\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '5592' '--' 'e:\programming\opencv\tests\FSRCNN_x2.py'
Traceback (most recent call last):
File "e:\programming\opencv\tests\FSRCNN_x2.py", line 19, in <module>
result = sr.upsample(image)
cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv_contrib\modules\dnn_superres\src\dnn_superres.cpp:172: error: (-213:The function/feature is not implemented) Unknown/unsupported superres algorithm: FSRCNN in function 'cv::dnn_superres::DnnSuperResImpl::upsample'
```PS E:\programming\opencv\tests> e:; cd 'e:\programming\opencv\tests'; & 'C:\Users\3diWorkstation\AppData\Local\Programs\Python\Python39\python.exe' 'c:\Users\3diWorkstation\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '5668' '--' 'e:\programming\opencv\tests\FSRCNN_x2.py'
Here’s the code I’m using:
import cv2
from cv2 import dnn_superres
# Create an SR object
sr = dnn_superres.DnnSuperResImpl_create()
# Read image
image = cv2.imread('./kitchen small.png')
# Read the desired model
path = "../models/FSRCNN_x2.pb"
path = "../models/EDSR_X4.pb"
sr.readModel(path)
# Set the desired model and scale to get correct pre- and post-processing
sr.setModel("edsr", 4)
# Upscale the image
result = sr.upsample(image)
# Save the image
cv2.imwrite("./upscaledx4.png", result)