使用Caffe预测遇到的问题
1. 在使用網絡預測圖像時,
prediction = net.predict( [input_image] )
出現: net.image_dims[0] 不是整數情況,
(2).甚至以為np.zeros()出現錯誤!最后發現
原因:net.image_dims
(3).出錯原因:mean_file= caffe_root+"python/caffe/imagenet/ilsvrc_2012_mean.npy"
??????? 引用了錯誤的文件
因此在初始化Net的時候不引用MeanFIle就可以:
net = caffe.Classifier(Model_File,PreTrained,mean_file,channel_swap=(2,1,0 )? , input_scale=255);
修改為:
net = caffe.Classifier(Model_File,PreTrained);
可以運行!
2.Caffe出現了IndexError: tuple index out of range問題;
prediction = net.predict( input_image? )#prediction = net.predict( ImageFile )
File "/home/wishchin/caffe-master/python/caffe/classifier.py", line 69, in predict
??? inputs[0].shape[2] ),
IndexError: tuple index out of range
好怪異的事情: caffe函數自身有bug啊!再一次載入運行竟然出現了輸入輸出不能 對應的問題,坑死!
input_image=caffe.io.load_image(ImageFile );
prediction = net.predict( input_image? )
第二次運行出現錯誤............
? (2).原因找出來了:prediction = net.predict( input_image? )
?????? 忘記 了填入列表,應該修改為:
????? prediction = net.predict( [input_image ]? )
3.
總結
以上是生活随笔為你收集整理的使用Caffe预测遇到的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 福尔马林作用
- 下一篇: lol网名大全骚气,lol逗比又嘲讽的名