相关疑难解决方法(0)

导入错误:无法为使用 opencv 的超分辨率 Python 示例导入名称“dnn_superres”

我正在尝试从以下网站运行一个放大图像的示例:https : //towardsdatascience.com/deep-learning-based-super-resolution-with-opencv-4fd736678066

这是我正在使用的代码:

import cv2
from cv2 import dnn_superres

# Create an SR object
sr = dnn_superres.DnnSuperResImpl_create()

# Read image
image = cv2.imread('butterfly.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)
Run Code Online (Sandbox Code Playgroud)

我已经从网站上下载了已经训练好的模型,名为“EDSR_x3.pb”,当我运行代码时,出现以下错误:

Traceback (most recent call last):
  File "upscale.py", line 2, in <module>
    from cv2 import dnn_superres
ImportError: cannot …
Run Code Online (Sandbox Code Playgroud)

python opencv neural-network opencv-contrib

8
推荐指数
4
解决办法
5753
查看次数

标签 统计

neural-network ×1

opencv ×1

opencv-contrib ×1

python ×1