PaddlePaddle / PaddleHub

Awesome pre-trained models toolkit based on PaddlePaddle. (400+ models including Image, Text, Audio, Video and Cross-Modal with Easy Inference & Serving)【安全加固,暂停交互,请耐心等待】
https://www.paddlepaddle.org.cn/hub
Apache License 2.0
12.74k stars 2.07k forks source link

在windows图像风格迁移时候最后一步运行style_transfer.py出现报错, UnimplementedError: There are no kernels which are registered in the pad2d operator. [Hint: Expected kernels_iter != all_op_kernels.end(), but received kernels_iter == all_op_kernels.end().] (at ..\paddle\fluid\framework\operator.cc:2273) [operator < pad2d > error] #2318

Closed brant3479 closed 8 months ago

brant3479 commented 10 months ago

待转换图片的绝对地址

picture = 'D:\style_transfer\pic.jpg' # 注意代码中此处为双反斜杠

风格图片的绝对地址

style_image = 'D:\style_transfer\fangao.jpg'

创建风格转移网络并加载参数

stylepro_artistic = hub.Module(name="stylepro_artistic")

读入图片并开始风格转换

result = stylepro_artistic.style_transfer( images=[{'content': cv2.imread(picture), 'styles': [cv2.imread(style_image)]}], visualization=True ) 复现步骤,当我在conda prompt执行python style_transfer.py时候预期会创建新文件夹transfer_result,并将转换后的文件保存到该目录下,实际上出现问题conda提示pad2d中没有注册内核,运算符pad2d错误。 我的stylepro_artistic已经是最新1.0.3,paddlepaddle,paddlehub也都升级为最新

w5688414 commented 8 months ago

您好,paddle2.6已经移除了fluid.layers.pad2d的API,需要对paddle进行降级,另外推荐您用linux来使用paddlehub,以下是我的环境:

paddle-bfloat==0.1.7
paddle2onnx==1.1.0
paddleaudio==1.1.0
paddlefsl==1.1.0
paddlehub==2.3.1
paddlenlp==2.5.2
paddlepaddle-gpu==2.5.1.post117
paddlesde==0.2.5
paddleslim==2.6.0

代码为:

import paddlehub as hub
import cv2

# 待转换图片的相对地址
picture = './style_transfer/pic.jpg'
# 风格图片的相对地址
style_image = './style_transfer/fangao.jpg'

# 创建风格转移网络并加载参数
stylepro_artistic = hub.Module(name="stylepro_artistic")

# 读入图片并开始风格转换
result = stylepro_artistic.style_transfer(
                    images=[{'content': cv2.imread(picture),
                                'styles': [cv2.imread(style_image)]}],
                    visualization=True
)