Caffe: AttributeError: 'module' object has no attribute 'LabelMap'

Created on 7 Jun 2016  Â·  11Comments  Â·  Source: weiliu89/caffe

When I perform command ./data/VOC0712/create_data.sh, it report
Traceback (most recent call last):
File "/root/lishengxi/caffe/data/VOC0712/../../scripts/create_annoset.py", line 103, in
label_map = caffe_pb2.LabelMap()
AttributeError: 'module' object has no attribute 'LabelMap' error

Most helpful comment

I am guessing you didn't setup the PYTHONPATH environment variable correctly.

You can either try:

export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH

where CAFFE_ROOT is the directory you have the code

or put it in your ~/.bashrc and run:

source ~/.bashrc

All 11 comments

I am guessing you didn't setup the PYTHONPATH environment variable correctly.

You can either try:

export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH

where CAFFE_ROOT is the directory you have the code

or put it in your ~/.bashrc and run:

source ~/.bashrc

Wei, thanks a lot.
I solve the problem according to your solution.

Hi, I'm still getting this error though I've already added $CAFFE_ROOT/python to my PYTHONPATH.
But I've built caffe from a master tree rather than from ssd tree. Might it be the case why I'm getting AttributeError: 'module' object has no attribute 'LabelMap' error, in other words, does master's and ssd's caffe installations differ?

You have to build the ssd branch.

Hi, I still get this problem though I have already added $CAFFE_ROOT/python to my PYTHONPATH and updated the ssd branch then rebuilt it just a few days ago. I named the ssd branch 'caffe-ssd' .

lab@lab:~/caffe-ssd$ echo $PYTHONPATH
:/home/lab/py-faster-rcnn/lib:/home/lab/py-faster-rcnn/caffe-fast-rcnn/python:/home/lab/caffe-ssd/python

I did:
make py
make test -j8
make runtest -j8
and my ~/.bashrc:
export PATH=$PATH:/usr/local/cuda-8.0/bin export LD_LIBRARY_PATH=:/usr/local/cuda-8.0/lib64 export PYTHONPATH=/home/fuming/caffe/python:$PYTHONPATH
still got
'module' object has no attribute 'LabelMap'

@FumingX you solved this?
i got this problem now,can you give me some advice?

@wishinger-li I just restarted the computer after installation, and it worked.

@FumingX I have solved this problem following these steps:

  1. export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH
  2. make py
  3. run ./data/VOC0712/create_data.sh
    hope that may help you.

1, open this file, ~/caffe-ssd/scripts/create_annoset.py
2,edit the file in path between [import sys] and [from caffe.proto import caffe_pb2].add this
sys.path.insert(0,'/home/xxx/caffe_ssd/python’)
beside add the /caffe-ssd/python to the bashrc way,this way work for me, hope it can help others.

sys.path.insert(0,'/home/xxx/caffe_ssd/python’) . This works for me while "adding to .bashrc" not.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZhihuaGao picture ZhihuaGao  Â·  6Comments

ShadowLau picture ShadowLau  Â·  4Comments

CPFLAME picture CPFLAME  Â·  5Comments

Sundrops picture Sundrops  Â·  4Comments

tumitx picture tumitx  Â·  5Comments