Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty __init.py__ file leads to import errors in Detection Demo of FastRCNN #2705

Closed
hellosaumil opened this issue Nov 30, 2017 · 16 comments
Closed
Assignees

Comments

@hellosaumil
Copy link

Under /Examples/Image/Detection directory __init.py__ is an empty file which leads to import errors while running DemoDetection.py and/or run_fast_rcnn.py.

@hellosaumil hellosaumil changed the title __init.py__ empty file leads to import errors in Detection Demo of FastRCNN Empty __init.py__ file leads to import errors in Detection Demo of FastRCNN Nov 30, 2017
@hellosaumil
Copy link
Author

hellosaumil commented Nov 30, 2017

I get errors as
ImportError: No module named 'utils.od_utils'
ImportError: No module named 'utils.map_helpers'
ImportError: No module named 'utils.rpn'
ImportError: No module named 'utils.cython_modules.cpu_nms'
ImportError: No module named 'cython_modules.cython_bbox'

etc. when running codes.

Please help. @KeDengMS @cha-zhang @sayanpa

@ke1337
Copy link

ke1337 commented Dec 1, 2017

Can you try add it to PYTHONPATH?

@hellosaumil
Copy link
Author

hellosaumil commented Dec 1, 2017

@KeDengMS I tried adding path 'my-path/Examples/Image/Detection/' to PYTHONPATH and exported it.

Yet, I get the following error :

  1. ImportError: No module named 'utils.cython_modules.cpu_nms' while running DetectionDemo.py
  2. ImportError: No module named 'utils.cython_modules.cython_bbox' while running run_fast_rcnn.py

I also tried adding __init__.py to utils, rpn and cython_modules directories.

@spandantiwari
Copy link
Contributor

You should add this to PYTHONPATH:
Examples/Image/Detection/utils/cython_modules

@hellosaumil
Copy link
Author

hellosaumil commented Dec 1, 2017

I tried adding cython_modules as already mentioned above.

But get following error: ImportError: No module named 'utils.cython_modules.cpu_nms'

@spandantiwari
Copy link
Contributor

You mentioned that you added 'my-path/Examples/Image/Detection/'. Did you try adding Examples/Image/Detection/utils/cython_modules?

Also, what's your platform and Python version? We have pre-built modules for Python 3.5 for Windows and for Python 3.4, 3.5, 3.6 for Linux. If you specs are different, then you will have to build these modules yourself.

@hellosaumil
Copy link
Author

hellosaumil commented Dec 1, 2017

@spandantiwari I tried all the possible permutations.

I'm running docker cntk-2.3-cpu-py35 image on MacOS. I also tried this process on AWS EC2.

@hellosaumil
Copy link
Author

hellosaumil commented Dec 2, 2017

@KeDengMS @spandantiwari

I was able to solve this problem by doing 2 things:

  1. Add 'my-path/Examples/Image/Detection/' to PYTHONPATH
  2. Rename files under cython_modules as
    2.1 cpu_nms.cpython-35m.so as cpu_nms.so
    2.2 cython_bbox.cpython-35m.so as cython_bbox.so

Note: One should rename files with cpython-3Xm based on their version of python; where 3X is 36 for python3.6 and 35 for python3.5.

Hope this helps.

@bartkowiaktomasz
Copy link

@hellosaumil
How did you manage to solve the issue with:
ImportError: No module named 'utils.rpn'
Did you just add the directory to PYTHONPATH?
I have tried adding:
export PYTHONPATH="$PYTHONPATH:/home/<path>/Detection/"
to ~/.bashrc
but it does not seem to work.

@hellosaumil
Copy link
Author

hellosaumil commented Feb 2, 2018

@bartkowiaktomasz After adding it to ~/.bashrc, did you source that file like, source ~/.bashrc or try running it in new tab/window? If not, then please do so.

If it still doesn't work, try creating an empty __init__.py file under the utils folder.

What is the version of your CNTK?

@bartkowiaktomasz
Copy link

@hellosaumil Creating __init__.py in utils helped! Thank you!
Btw. I though the issue with creating empty init files was resolved in earlier versions of Python (I'm using 3.5).

@devedse
Copy link

devedse commented May 10, 2018

I've tried changing file names and things like that but keep running into random errors like stated above:

image

image

When I change even more filenames the issue doesn't get better

image

image

Any ideas?

Also wouldn't it be a good idea that if we apparently need these files renamed that we actually check this in?

@spandantiwari
Copy link
Contributor

@devedse You need to set the PYTHONPATH varibale to (also) point at the folder with cython modules. Something like:
set PYTHONPATH=E:\cntk\Examples\Image\Detection\utils\cython_modules;%PYTHONPATH%

@devedse
Copy link

devedse commented May 11, 2018

@spandantiwari I got it configured like this:
image

But still see this error:
image

@spandantiwari
Copy link
Contributor

My guess is that you are on Windows. What Python version do you have? For Windows, we have cython modules for Python 3.5 only (Linux we have for 3.5 and 3.6).

@alexberd
Copy link

alexberd commented Feb 14, 2020

You mentioned that you added 'my-path/Examples/Image/Detection/'. Did you try adding Examples/Image/Detection/utils/cython_modules?

Also, what's your platform and Python version? We have pre-built modules for Python 3.5 for Windows and for Python 3.4, 3.5, 3.6 for Linux. If you specs are different, then you will have to build these modules yourself.

@spandantiwari Would it be possible to further illustrate how to build those modules for python 3.6?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants