How to fix "ImportError: No module named voc_layers"?

416 views
Skip to first unread message

john1...@gmail.com

unread,
Dec 14, 2016, 5:17:55 AM12/14/16
to Caffe Users
I am using the fcn code at https://github.com/shelhamer/fcn.berkeleyvision.org. I compiled the caffe in the folder /home/john/caffe without error. 

make all -j8
make test
make runtest

[----------] Global test environment tear-down
[==========] 2025 tests from 267 test cases ran. (301390 ms total)
[  PASSED  ] 2025 tests.

I also uncommand the line  `WITH_PYTHON_LAYER := 1`. And setting in the bashrc file as
export PYTHONPATH=/home/john/caffe/python
I test the import caffe and it worked
>>>import caffe
>>>

Now, I go to the `/home/fcn.berkeleyvision.org/voc-fcn32s`, and run the training code with command
../../caffe/build/tools/caffe train -solver=solver.prototxt

However, it got a error that is
I1214 19:14:45.049516 10747 layer_factory.hpp:77] Creating layer data
ImportError: No module named voc_layers
The error looks setting path. I tried to fix it by edit the file solver.py as follows:
import os,sys
sys
.path.append('/home/john/fcn.berkeleyvision.org')


But it cannot fix. How could I fix it? Thank all



Arghavan Arafati

unread,
Jan 17, 2017, 1:45:47 PM1/17/17
to Caffe Users
Hi,

Have you solved the problem? I have got the same error :/

Andrew Wallis

unread,
May 22, 2017, 11:22:01 AM5/22/17
to Caffe Users
I am getting the exact same error as well - did you find a solution to the issue?

Suthakar N. M.

unread,
Aug 10, 2017, 4:07:30 AM8/10/17
to Caffe Users
Is this problem solved. I too get the same error

Jonathan R. Williford

unread,
Aug 10, 2017, 3:35:45 PM8/10/17
to Suthakar N. M., Caffe Users
If the python paths and module is setup correctly, the following should work in python (or ipython):

import voc_layer

The following is a step in the right direction:

import os, sys
sys.path.append('/home/john/fcn.berkeleyvision.org')

Assuming that the path is correct. Using the environment variable PYTHONPATH would also work. It looks like the fcn.berkeleyvision.org directory doesn't have an "__init__.py" file though, which makes it so that it isn't a valid python module (for Python version <3.3). Trying creating an empty __init__.py file inside the fcn.berkeleyvision.org.

So:
  1. Make sure that PYTHONPATH or the sys.path.append(...) path exists and that
  2. it contains an __init__.py file (just type "touch __init__.py" in Linux shell).
  3. Try "import voc_layer" in python.
  4. If that doesn't work, got to the directory that contains the voc_layer.py and try "import voc_layer" inside python again.
Hope this helps!
Jonathan

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users+unsubscribe@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/cb9e545b-be62-4420-a2a3-5c6c1ad0598c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Skr

unread,
Aug 17, 2017, 6:43:27 AM8/17/17
to Caffe Users, sutha...@gmail.com
Thanks Jonathan. This Helps
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.

To post to this group, send email to caffe...@googlegroups.com.
Message has been deleted

Jonathan R. Williford

unread,
Oct 16, 2017, 11:58:21 AM10/16/17
to Olzhas Kadyrakunov, Caffe Users
Following those steps can be helpful in figuring out what is wrong when using a custom python layer. It is independent of what interface you use (except for the sys.path of step 1, you need to use PYTHONPATH variable).

Jonathan

On Oct 16, 2017 4:04 PM, "Olzhas Kadyrakunov" <olzhas.ka...@gmail.com> wrote:

Thanks a lot for your reply Jonathan! I'm getting the same (no voc_layer module) error. However, I'm running everything in terminal ("build/tools/caffe train -solver examples/FCN/voc-fcn8s/solver.prototxt"). Do you have any idea about what could be done in this case? I would appreciate any input!

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users+unsubscribe@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages