I am trying to recognize a picture by caffe, and the code is following. But when I debugged it, it appears:
AttributeError: module 'caffe' has no attribute 'io'.
# -*- coding: utf-8 -*-
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
caffe_root = '/Users/qiaojie/caffe'
sys.path.insert(0, caffe_root + 'python3')
import caffe
MODEL_FILE = '/Users/qiaojie/caffe/examples/mnist/lenet.prototxt'
PRETRAINED = '/Users/qiaojie/caffe/examples/mnist/lenet_iter_10000.caffemodel'
IMAGE_FILE = '/Users/qiaojie/caffe/examples/images/test4.bmp'
input_image = caffe.io.load_image(IMAGE_FILE, color=False)
net = caffe.Classifier(MODEL_FILE, PRETRAINED)
prediction = net.predict([input_image], oversample = False)
caffe.set_mode_cpu()
print ('predicted class:',prediction[0].argmax())
Does anyone meet with the same problem?
Could anyone help me?
thx in advance!