models icon indicating copy to clipboard operation
models copied to clipboard

When run train.py in object_detection, then "deployment" cannot be found ?

Open Jennyidream0318 opened this issue 9 years ago • 28 comments

Traceback (most recent call last): File "train.py", line 51, in from object_detection import trainer File "/root/models-master/object_detection/trainer.py", line 33, in from deployment import model_deploy ImportError: No module named deployment

Jennyidream0318 avatar Jul 20 '17 09:07 Jennyidream0318

Please follow the object detection API installation instructions, which will add the deployment module to your PYTHONPATH.

Feel free to reopen this issue if there is a bug in the installation instructions. Thanks!

asimshankar avatar Jul 21 '17 02:07 asimshankar

Hey I am running the api on Windows .... I got the same error ... What is the command for windows the add deployment module to PYTHONPATH

jayshah19949596 avatar Sep 03 '17 08:09 jayshah19949596

Seeing the same problem right now on Ubuntu even after doing the export as per the instruction.

Here's my trace: File "train.py", line 51, in from object_detection import trainer File "build/bdist.linux-x86_64/egg/object_detection/trainer.py", line 33, in from deployment import model_deploy ImportError: No module named deployment

metaranha avatar Sep 18 '17 00:09 metaranha

For ubuntu @metaranha

  1. If models is located at /home/tensorflow/models/
  2. Edit ~/.bashrc and puts export PYTHONPATH="${PYTHONPATH}:/home/tensorflow/models:/home/tensorflow/models/slim/"

For windows, @jayshah19949596

  1. Goto My Computer > Properties > Advanced System Settings > Environment Variables > New
  2. If models is located at c:\tensorflow
  3. Variable name: Type PYTHONPATH
  4. Variable value: Fill-in your c:\tensorflow\models and c:\tensorflow\models\slim directory

ninetu avatar Sep 18 '17 13:09 ninetu

@ninetu Right, I've exported the correct directory, but I'm still hitting the same snag.

On Mon, Sep 18, 2017 at 9:12 AM, ninetu [email protected] wrote:

For ubuntu @metaranha https://github.com/metaranha

  1. If models https://github.com/tensorflow/models is located at /home/tensorflow/models/
  2. Edit ~/.bashrc and puts export PYTHONPATH="${PYTHONPATH}:/home/tensorflow/models:/home/ tensorflow/models/slim/"

For windows, @jayshah19949596 https://github.com/jayshah19949596

  1. Goto My Computer > Properties > Advanced System Settings > Environment Variables > New
  2. If models https://github.com/tensorflow/models is located at c:\tensorflow
  3. Variable name: Type PYTHONPATH
  4. Variable value: Fill-in your c:\tensorflow\models and c:\tensorflow\models\slim directory

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1992#issuecomment-330214819, or mute the thread https://github.com/notifications/unsubscribe-auth/AEe4RL9-KyYy3Q0DtknX2_4zrl6zV0ixks5sjmw1gaJpZM4Od2ZU .

metaranha avatar Sep 18 '17 13:09 metaranha

Make sure you puts both models and models/slim ?

On Mon, Sep 18, 2017 at 8:25 PM, emilymaxima [email protected] wrote:

@ninetu https://github.com/ninetu Right, I do have the correct directory exported, but I'm still hitting the same snag.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1992#issuecomment-330219159, or mute the thread https://github.com/notifications/unsubscribe-auth/AVuGRzytBQ2T8DVU2arzmPFilfi3lGmmks5sjm9BgaJpZM4Od2ZU .

ninetu avatar Sep 18 '17 13:09 ninetu

Yes, both are exported and I'm still seeing the same "no module named deployment" message.

On Mon, Sep 18, 2017 at 9:30 AM, ninetu [email protected] wrote:

Make sure you puts both models and models/slim ?

On Mon, Sep 18, 2017 at 8:25 PM, emilymaxima [email protected] wrote:

@ninetu https://github.com/ninetu Right, I do have the correct directory exported, but I'm still hitting the same snag.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/tensorflow/models/issues/1992#issuecomment-330219159 , or mute the thread <https://github.com/notifications/unsubscribe-auth/ AVuGRzytBQ2T8DVU2arzmPFilfi3lGmmks5sjm9BgaJpZM4Od2ZU> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1992#issuecomment-330220755, or mute the thread https://github.com/notifications/unsubscribe-auth/AEe4RBJkUbYZ-nqzrn56t9R45JcU-8CTks5sjnBlgaJpZM4Od2ZU .

metaranha avatar Sep 18 '17 13:09 metaranha

Have you put it in as c:\tensorflow\models:c:\tensorflow\models\slim in the variable value as if you try to do 2 separate PYTHONPATH one replaces the other I was having the same problem till I tried this and then opened a new cmd window. This worked for me.

zshobbs avatar Sep 21 '17 06:09 zshobbs

I'm building on Ubuntu, but I actually did find a solution to the problem. It's embarrassing, but c'est la vie.

On Ubuntu, you have to 'su' to root and THEN set the path. The path doesn't get applied globally, but you need root permissions to run the script, so the path has to be set for a root-level account before doing all of this. Before, I had been trying to set the path as an unprivileged user, and then escalate, but noticed the path wasn't set.

Did all that, and problem solved!

On Thu, Sep 21, 2017 at 2:50 AM, zshobbs [email protected] wrote:

Have you put it in as c:\tensorflow\models:c:\tensorflow\models\slim in the variable value as if you try to do 2 separate PYTHONPATH one replaces the other i was having the same problem till I tried this and then opened a new cmd window.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1992#issuecomment-331067926, or mute the thread https://github.com/notifications/unsubscribe-auth/AEe4RENGmd_G04oEkc2HE_mfi_ubNRbqks5skgc6gaJpZM4Od2ZU .

metaranha avatar Sep 21 '17 11:09 metaranha

For linux users:

protoc object_detection/protos/*.proto --python_out=.
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

Solved my issue

beyhangl avatar Oct 24 '17 07:10 beyhangl

I had the same problem. make sure you export the right path. namely /models/research and /models/research/slim

you can check with echo $PYTHONPATH in linux and echo %PYTHONPATH% in windows if it's set alright. try cd-ing into those directories with absolute paths.

there is no need to run anything as root, unless you do systemwide installs with pip or somesuch. you can put export $PYTHONPATH:/absolute/path/to/models/research:/absolute/path/to/models/research/slim at the end of ~/.bashrc and you won't need to type it every time.

FalcoGer avatar Nov 29 '17 19:11 FalcoGer

from slim.deployment import model_deploy

Viveco avatar Dec 18 '17 03:12 Viveco

For windows 7,

  1. Go to My Computer > Properties > Advanced System Settings > Environment Variables > New (The first button)
  2. Add
Variable name: PYTHONPATH
Variable value: c:\tensorflow\models;c:\tensorflow\models\slim

Remember, using semicolon between 2 paths.

lekhanh1234 avatar Dec 25 '17 18:12 lekhanh1234

@FalcoGer , I am running this whole thing on mac. I tried adding as you mentioned in my bash_profile file but still getting "ImportError: No module named deployment" error.

this is how my .bash_profile looks after i add the line as you mentioned. screen shot 2018-01-16 at 12 54 44 pm

This is the error i get screen shot 2018-01-16 at 12 56 51 pm

amitsood avatar Jan 16 '18 07:01 amitsood

If useful for anyone, for pycharm users, simply set research/slim as Sources Root by right clicking the folder and find Mark Directory As can solve the problem.

xiaoyuliu avatar Jan 17 '18 17:01 xiaoyuliu

This work for me in windows:

  • Copy relevant deployment files from the \models\slim directory
  • paste it to Python\Lib\site-packages directory

then run again.It will work!

CHAMOD avatar Jan 21 '18 14:01 CHAMOD

As of now, the slim folder has been moved to models/research. So if [models][1] is in the /home directory, do the following to resolve the issue:

1- Open the ~/.bashrc and add the following line to the end of the file:

export PYTHONPATH="$PYTHONPATH:/home/models:/home/models/research/slim/"

3- Close the file and do source ~/.bashrc

ahmadra avatar Mar 02 '18 19:03 ahmadra

edit ./bash_profile in Mac os

lightningsoon avatar Mar 13 '18 09:03 lightningsoon

Following @CHAMOD recommendation,copy and paste deployment and nets folder. This works for me as well.

pomonam avatar Apr 23 '18 16:04 pomonam

Hi I have add the directories o my python path but am still facing the same problem

SalsHacker avatar Jun 28 '18 16:06 SalsHacker