Caffe 模型为每个图像提供相同的输出

2023-12-30

我刚刚使用预定义的 prototxt 和 caffemodel 文件在 caffe 中加载了 alexnet。然而,将任何图像发送到模型都会返回与 fc7 层的输出相同的值。

这是代码片段

net=caffe.Net('alexnet/train_val.prototxt','alexnet/bvlc_alexnet.caffemodel',caffe.TEST) 

for image in images:
    im = np.array(caffe.io.load_image(image))
    im = caffe.io.resize_image(im, (227, 227))
    im = np.array(im,dtype=np.float32)
    im =255*im;
    im = im[:,:,::-1]
    im -= np.array(((104.00698793,116.66876762,122.67891434)))
    im = im.transpose(2,0,1)
    net.blobs['data'].reshape(1,*im.shape)
    net.blobs['data'].data[...] = im
    net.forward()
    fc = net.blobs['fc7'].data #Always the same value

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Caffe 模型为每个图像提供相同的输出 的相关文章

随机推荐