AttributeError: module 'caffe' has no attribute 'io'.

193 views
Skip to first unread message

Jie Qiao

unread,
Apr 6, 2017, 8:54:54 PM4/6/17
to Caffe Users
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!
caffe_test.py

Nima Forouzandeh

unread,
Mar 15, 2022, 1:30:08 PM3/15/22
to Caffe Users
Hi,
could you solve this issue?
I get a similar error from my code: 
module 'caffe' has no attribute 'Classifier'

I think these two can be solved the same way. 
Reply all
Reply to author
Forward
0 new messages