飞风清影 2022-08-27 18:31
浏览 35
已结题

net.forward() 报错

问题遇到的现象和发生背景

使用素材: https://github.com/PJ-Finlay/Neural-Style-Transfer-Images/

问题相关代码,请勿粘贴截图 ?%ra=card

from tracemalloc import start
import cv2
import matplotlib.pylab as pylab
import imutils
import time
import numpy as np

  • 写回答

1条回答 默认 最新

  • 飞风清影 2022-08-27 18:35
    关注

    net.forward() 报错
    python
    opencv
    问题遇到的现象和发生背景
    使用素材: https://github.com/PJ-Finlay/Neural-Style-Transfer-Images/

    问题相关代码,请勿粘贴截图 ?%ra=card
    from tracemalloc import start
    import cv2
    import matplotlib.pylab as pylab
    import imutils
    import time
    import numpy as np

    model = 'neural-style-transfer/models/eccv16/starry_night.t7'

    assumes the pre-trained torch file is in the current path

    model = './neural-style-transfer/starry_night.t7'
    print("loading style transfer nodel...")
    net = cv2.dnn.readNetFromTorch(model)

    image = cv2.imread('./images/monalisa.jpg') # the current image path

    image = cv2.imread('./neural-style-transfer/Images/originals/three_beauties_of_the_present_time.jpeg')

    image = cv2.imread('F:/ImageProcessing/Chapter11/neural-style-transfer/Images/getty.jpg')

    pylab.imshow(image)
    image = imutils.resize(image, width=600)
    (h, w) = image.shape[:2]
    b, g, r = np.mean(image[...,0]), np.mean(image[...,1]), np.mean(image[...,2])

    construct a blob from the image, set the input, and then perform a forward pass of the network

    blob = cv2.dnn.blobFromImages(image, 1.0, (w,h), (b,g,r), swapRB=False, crop=False)
    net.setInput(blob)
    start = time.time()
    output = net.forward()
    end = time.time()

    运行结果及报错内容

    error Traceback (most recent call last)
    f:\ImageProcessing\Chapter11\Chapter11.ipynb Cell 21 in <cell line: 27>()
    25 net.setInput(blob)
    26 start = time.time()
    ---> 27 output = net.forward()
    28 end = time.time()

    error: OpenCV(4.6.0) d:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layer_internals.hpp:110: error: (-2:Unspecified error) Can't create layer "l1_NoiseFill" of type "NoiseFill" in function 'cv::dnn::dnn4_v20220524::detail::LayerData::getLayerInstance'

    我的解答思路和尝试过的方法

    更换图片,更新OpenCV版本,均未解决!

    我想要达到的结果

    跑通代码,并理解报错原因!

    评论

报告相同问题?

问题事件

  • 系统已结题 9月4日
  • 创建了问题 8月27日

悬赏问题

  • ¥30 java spring boot2.5.3版本websocket连不上
  • ¥15 openFOAM DPMFoam
  • ¥15 将查询到的值,赋值到table指定行中
  • ¥50 docker容器内部启动shell脚本多命令
  • ¥15 请问python的selenium怎么设置referer
  • ¥15 请教下, VS QT 环境下, QTOPCUA 的源文件报错,这种情况咋查呢 ?
  • ¥20 UNITY webgl关于文档的上传和下载问题
  • ¥15 安霸cv22 + rtl8211f 千兆,udp传输丢包
  • ¥15 关于区块链和边缘环境搭建的相关问题
  • ¥15 windows远程桌面断卡重连软件卡顿问题