import cv2
from cv2 import dnn_superres
sr = dnn_superres.DnnSuperResImpl_create()
path = ‘LapSRN_x8.pb’
sr.readModel(path)
sr.setModel(‘lapsrn’, 8)
image = cv2.imread(‘1_output_face_0.jpg’)
upscaled = sr.upsample(image)
cv2.imwrite(‘1_output_face_0_output.jpg’, upscaled)
The code is as mentioned above and the error is as follows
ImportError Traceback (most recent call last)
Cell In [9], line 2
1 import cv2
----> 2 from cv2 import dnn_superres
4 sr = dnn_superres.DnnSuperResImpl_create()
6 path = ‘LapSRN_x8.pb’
ImportError: cannot import name ‘dnn_superres’ from ‘cv2’ (/usr/local/lib/python3.8/dist-packages/cv2/init.py)
The version of OpenCV is 4.7.0 and I tried various methods to fix this error but it still does not work.
I would appreciate it if someone could help me out with this. Thanks in advance.