0
我試圖從caffe模型動物園(沒有微調)運行pretrained googlenet模型。該模型和deploy.prototxt都從https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet咖啡GoogleNet模型預測總是相同
下載下面是我使用的代碼:
net = caffe.Net('deploy.prototxt', 'bvlc_googlenet.caffemodel', caffe.TEST)
net.blobs['data'].reshape(1,3,224,224)
image_path = '1.png'
img = caffe.io.load_image(image_path)
img = caffe.io.resize(img, (224, 224, 3))
# mean subtraction
img[0,:,:] -= 104/255.0
img[1,:,:] -= 117/255.0
img[2,:,:] -= 123/255.0
# 224,224,3 -> 3,224,224
img = np.transpose(img, (2, 0, 1))
out = net.forward(data=np.array([img]))['prob']
print(np.argmax(out))
貌似模型加載罰款,但無論輸入的它總是輸出相同的類(885) 。可能是什麼原因?
UPD:實際上,同樣的問題適用於其他模型,不管我是否意味着減法與否,只是總是檢測到的類會改變一些不同。
真棒,謝謝。 –