首页 新闻 会员 周边 捐助

caffe python接口中Net.Classifier运行导致系统崩溃

0
[待解决问题]

我的电脑是Ubuntu14.04LTS,然后使用例子里面的

时,每次运行到这里时就崩溃了,提示的是系统错误,还有使用MATLAB的接口作分类的时候也有问题,还没找到什么原因,希望大神帮帮忙,耽搁很长时间了。。


net = caffe.Classifier(MODEL_FILE, PRETRAINED,
mean=np.load(caffe_root + '/python/caffe/imagenet/ilsvrc_2012_mean.npy').mean(1),
channel_swap=(2,1,0),
raw_scale=255,
image_dims=(480, 360))

提示系统错误,

 

完整代码如下:

# -*- coding: utf-8 -*-
"""
Created on Thu Jun 11 14:48:26 2015

@author: raoqiang
"""

import numpy as np
import matplotlib.pyplot as plt

#matplotlib inline

# Make sure that caffe is on the python path:
caffe_root = '/home/raoqiang/OpenSDK/caffe-master2.0' # this file is expected to be in {caffe_root}/examples
import sys
sys.path.insert(0, caffe_root + 'python')
sys.path.append('/home/raoqiang/OpenSDK/caffe-master2.0/python')

import caffe

# Set the right path to your model definition file, pretrained model weights,
# and the image you would like to classify.
MODEL_FILE = caffe_root+'/models/bvlc_reference_caffenet/deploy.prototxt'
PRETRAINED =caffe_root+'/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'
IMAGE_FILE = caffe_root+'/examples/images/cat.jpg'

import os
#from /home/raoqiang/OPEN_SDK/caffe-master/scripts/download_model_binary.py import main as mymain
if not os.path.isfile(PRETRAINED):
print("Downloading pre-trained CaffeNet model...")
#!../scripts/download_model_binary.py ../models/bvlc_reference_caffenet
#mymain ../models/bvlc_reference_caffenet
print 'set GPU'
caffe.set_mode_gpu()
print 'construct Classifier'
mean=np.load(caffe_root + '/python/caffe/imagenet/ilsvrc_2012_mean.npy').mean(1)
#print mean

print 'load image'
input_image = caffe.io.load_image(IMAGE_FILE)
plt.imshow(input_image)

'''
net = caffe.Classifier(MODEL_FILE, PRETRAINED,
mean=np.load(caffe_root + '/python/caffe/imagenet/ilsvrc_2012_mean.npy').mean(1),
channel_swap=(2,1,0),
raw_scale=255,
image_dims=(256, 256))
'''

net = caffe.Classifier(MODEL_FILE, PRETRAINED,
mean=np.load(caffe_root + '/python/caffe/imagenet/ilsvrc_2012_mean.npy').mean(1),
channel_swap=(2,1,0),
raw_scale=255,
image_dims=(480, 360))
print net

print 'load image'
input_image = caffe.io.load_image(IMAGE_FILE)
print 'show image'
plt.imshow(input_image)
prediction = net.predict([input_image]) # predict takes any number of images, and formats them for the Caffe net automatically
print 'prediction shape:', prediction[0].shape
plt.plot(prediction[0])
print 'predicted class:', prediction[0].argmax()

Erdos001的主页 Erdos001 | 菜鸟二级 | 园豆:202
提问于:2015-07-03 17:36
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册