问题遇到的现象和发生背景
使用素材: 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
使用素材: https://github.com/PJ-Finlay/Neural-Style-Transfer-Images/
from tracemalloc import start
import cv2
import matplotlib.pylab as pylab
import imutils
import time
import numpy as np
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/starry_night.t7'
print("loading style transfer nodel...")
net = cv2.dnn.readNetFromTorch(model)
image = cv2.imread('./neural-style-transfer/Images/originals/three_beauties_of_the_present_time.jpeg')
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])
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版本,均未解决!
跑通代码,并理解报错原因!