EdjeElectronics / TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10

How to train a TensorFlow Object Detection Classifier for multiple object detection on Windows
Apache License 2.0
2.92k stars 1.3k forks source link

No module named 'nets' #150

Open TechGenius28 opened 5 years ago

TechGenius28 commented 5 years ago

I am experiencing an issue when running the 'train.py' command.

This error keeps reoccurring:

File "train.py", line 52, in from object_detection.builders import model_builder File "C:\Users\owner\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\model_builder.py", line 30, in from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "C:\Users\owner\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'

Please could somebody help me out. Thanks

drfikrah commented 5 years ago

i have same problem too. any solution?

vdsprakash commented 5 years ago

once keep the defintion of the model_builder.py and faster_rcnn_inception_resnet_v2_feature_extractor.py

vdsprakash commented 5 years ago

i have same problem too. any solution?

I can solve your problem, once share me your project directory list.

venkateshbabusekar commented 5 years ago

run this command set PYTHONPATH=C:\tensorflow1\models set PYTHONPATH=C:\tensorflow1\models\research set PYTHONPATH=C:\tensorflow1\models\research\slim

run the following commands from the C:\tensorflow1\models\research directory:

C:\tensorflow1\models\research> python setup.py build C:\tensorflow1\models\research> python setup.py install

nickguimaraes commented 5 years ago

I was having the same error and this solved my problem https://github.com/tensorflow/models/issues/1842#issuecomment-377925135

vdsprakash commented 5 years ago

keep the nets folder in the object detection folder and change your importing code to

from object_dectection.nets import (your_required_python file or class/function in python file)

Akshaysharma29 commented 5 years ago

keep the nets folder in the object detection folder nets folder is present in research/slim directory or From tensorflow/models/research/ run this command on terminal export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim

aaron-jencks commented 5 years ago

in the C:\tensorflow1\models\research\slim directory run python setup.py build python setup.py install

models/research/slim HAS ITS OWN setup.py!!!!!!!!!!!!!

AlanNaoto commented 5 years ago

in the C:\tensorflow1\models\research\slim directory run python setup.py build python setup.py install

models/research/slim HAS ITS OWN setup.py!!!!!!!!!!!!!

Worked perfectly! Thanks a lot.

rejj1234 commented 5 years ago

Traceback (most recent call last): File "train.py", line 51, in from object_detection.builders import model_builder File "C:\Users\regie\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\model_builder.py", line 35, in from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "C:\Users\regie\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'

How can I fix this error?

AlanNaoto commented 5 years ago

Traceback (most recent call last): File "train.py", line 51, in from object_detection.builders import model_builder File "C:\Users\regie\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\model_builder.py", line 35, in from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "C:\Users\regie\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'

How can I fix this error?

That's because your train.py script is not finding the scripts from the nets folder. You should do as iggy12345 said and install those packages to the python you are using.

rejj1234 commented 5 years ago

Thank you very much.

On Mon, 11 Mar 2019 11:04 PM Alan notifications@github.com wrote:

Traceback (most recent call last): File "train.py", line 51, in from object_detection.builders import model_builder File "C:\Users\regie\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\model_builder.py", line 35, in from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "C:\Users\regie\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'

How can I fix this error?

That's because your train.py script is not finding the scripts from the nets folder. You should do as iggy12345 said and install those packages to the python you are using.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/issues/150#issuecomment-471576976, or mute the thread https://github.com/notifications/unsubscribe-auth/AuL1K1LPfMCXS_w5mAbWouSTr7E8-8Gzks5vVnCOgaJpZM4W1SxU .

harsath commented 5 years ago

in the C:\tensorflow1\models\research\slim directory run python setup.py build python setup.py install

models/research/slim HAS ITS OWN setup.py!!!!!!!!!!!!!

IT WORKS FLAWLESSLY!!!!! THANK YOU SO VERY MUCH

MohammadDabbas commented 5 years ago

Hi guys I'm having a similar error when I'm trying to run the training using this command: python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_coco.config

this is the error that I'm having: Traceback (most recent call last): File "train.py", line 51, in <module> from object_detection.builders import model_builder File "C:\tensorflow1\models\research\object_detection\builders\model_builder.py", line 35, in <module> from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "C:\tensorflow1\models\research\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in <module> from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'

note: the setup.py file is already exist in the slim folder directory plz guys help me out

Itachi-Uchia commented 5 years ago

@MohammadDabbas did you get the solution??? Bcz im getting the same scenario

Itachi-Uchia commented 5 years ago

in the C:\tensorflow1\models\research\slim directory run python setup.py build python setup.py install models/research/slim HAS ITS OWN setup.py!!!!!!!!!!!!!

IT WORKS FLAWLESSLY!!!!! THANK YOU SO VERY MUCH

Brother I have the setup file but the 'install' wont run having the error as

"could not create 'build':Cannot create a file when that file already exits"

If you know the solution then plz help

SiddharthSingi commented 5 years ago

in the C:\tensorflow1\models\research\slim directory run python setup.py build python setup.py install models/research/slim HAS ITS OWN setup.py!!!!!!!!!!!!!

IT WORKS FLAWLESSLY!!!!! THANK YOU SO VERY MUCH

Brother I have the setup file but the 'install' wont run having the error as "could not create 'build':Cannot create a file when that file already exits" If you know the solution then plz help

Same problem here, if anyone has a solution then please post it. I have tried the solutions mentioned above

kamal0803 commented 5 years ago

in the C:\tensorflow1\models\research\slim directory run python setup.py build python setup.py install models/research/slim HAS ITS OWN setup.py!!!!!!!!!!!!! IT WORKS FLAWLESSLY!!!!! THANK YOU SO VERY MUCH Brother I have the setup file but the 'install' wont run having the "could not create 'build':Cannot create a file when that file already exits" If you know the solution then plz help

Same problem here, if anyone has a solution then please post it. I have tried the solutions mentioned above Same problem

SiddharthSingi commented 5 years ago

Solution: @kamal0803 If you open python on your shell, run import sys and then print(sys.path) you will see a list of all the PYTHONPATH items in a list. To remove this error, this list must include a path to the slims, models and research directory. You can try set PYTHONPATH=path_name_to_directory. However if that does not work then you can also consider manually adding the pathname by going on My PC --> Properties -->Advanced System Settings --> Environment Variables and then add a new variable in System Variables.

This worked for me, also remember that even after you have added the pathnames, you will need to restart the shell or sometimes even the PC for it to reflect of sys.path

kamal0803 commented 5 years ago

Solution: @kamal0803 If you open python on your shell, run import sys and then print(sys.path) you will see a list of all the PYTHONPATH items in a list. To remove this error, this list must include a path to the slims, models and research directory. You can try set PYTHONPATH=path_name_to_directory. However if that does not work then you can also consider manually adding the pathname by going on My PC --> Properties -->Advanced System Settings --> Environment Variables and then add a new variable in System Variables.

This worked for me, also remember that even after you have added the pathnames, you will need to restart the shell or sometimes even the PC for it to reflect of sys.path

github

Screenshot (19)

Screenshot (21)

I tried your solution, but its still not working..Please give another solution to this problem

kamal0803 commented 5 years ago

Solution: @kamal0803 If you open python on your shell, run import sys and then print(sys.path) you will see a list of all the PYTHONPATH items in a list. To remove this error, this list must include a path to the slims, models and research directory. You can try set PYTHONPATH=path_name_to_directory. However if that does not work then you can also consider manually adding the pathname by going on My PC --> Properties -->Advanced System Settings --> Environment Variables and then add a new variable in System Variables.

This worked for me, also remember that even after you have added the pathnames, you will need to restart the shell or sometimes even the PC for it to reflect of sys.path

Also, I am using a CPU version of tensorflow.

SiddharthSingi commented 5 years ago

I am also using a CPU version, but that should not be an issue, where have you saved the environment variable, mine is saved like this: PYTHONPATH

And also on your cmd, run python then import sys then print(sys.path). You may have added your paths to PATH variable but you need to add it to PYTHONPATH variable in the environment variables like in the image above

kamal0803 commented 5 years ago

I am also using a CPU version, but that should not be an issue, where have you saved the environment variable, mine is saved like this: PYTHONPATH

And also on your cmd, run python then import sys then print(sys.path). You may have added your paths to PATH variable but you need to add it to PYTHONPATH variable in the environment variables like in the image above

Sir,

Its still not working. Please help. I have sent the screenshots

Can it be a possibility that the files might been corrupt because of so many hit and trials.??

Screenshot (24)

Screenshot (26)

Screenshot (27)

SiddharthSingi commented 5 years ago

Can you check in your folders if you have the nets folder inside slim directory?

kamal0803 commented 5 years ago

Yes sir

Screenshot (28)

kamal0803 commented 5 years ago

Can you check in your folders if you have the nets folder inside slim directory?

Sir,the error I got, I checked it on github..The link to its solution is

https://github.com/tensorflow/models/issues/5138

But i am not able to find a solution Please help.

lintujizoarakal777 commented 5 years ago

run this command set PYTHONPATH=C:\tensorflow1\models set PYTHONPATH=C:\tensorflow1\models\research set PYTHONPATH=C:\tensorflow1\models\research\slim

run the following commands from the C:\tensorflow1\models\research directory:

C:\tensorflow1\models\research> python setup.py build C:\tensorflow1\models\research> python setup.py install

Super bro...... Thank you soooooo much

rejj1234 commented 5 years ago

you should do the setpython path so that the error will disappear.

On Thu, 18 Apr 2019 1:26 PM Itachi-Uchia notifications@github.com wrote:

@MohammadDabbas https://github.com/MohammadDabbas did you get the solution??? Bcz im getting the same scenario

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/issues/150#issuecomment-484360747, or mute the thread https://github.com/notifications/unsubscribe-auth/ALRPKKZDP363DGZFKRBMJBDPRAA6PANCNFSM4FWVFRKA .

tamasino52 commented 5 years ago

I'm already do that. But " No module named 'nets' " message still occurs

rejj1234 commented 5 years ago

make sure your directory is correct

On Wed, Aug 7, 2019, 16:34 RedBean_Kim notifications@github.com wrote:

I'm already do that. But ModuleNotFoundError: No module named 'nets' message still occurs

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/issues/150?email_source=notifications&email_token=ALRPKK2DDY4TZQR5PIXLPSDQDKCHVA5CNFSM4FWVFRKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3XUZYQ#issuecomment-518999266, or mute the thread https://github.com/notifications/unsubscribe-auth/ALRPKK4GTVZXWTUQZVOQ2X3QDKCHVANCNFSM4FWVFRKA .

kamal0803 commented 5 years ago

@tamasino52 There might be a possibility that the files must have got corrupt. In this case, do everything from scratch and u will get the desired result. It happened the same with me.

aliakgoz commented 5 years ago

I'm already do that. But " No module named 'nets' " message still occurs

for colab you can try this import os os.environ['PYTHONPATH']=os.environ['PYTHONPATH']+':/content/models/research/slim'

ramapsam commented 4 years ago

set PYTHONPATH=C:\tensorflow1\models\research\slim

i'm already do like this but this appear

this = _pywrap_tensorflow_internal.new_CheckpointReader(filename) tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt: Not found: FindFirstFile failed for: C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28 : The system cannot find the path specified. ; No such process

anny solution?

aliakgoz commented 4 years ago

set PYTHONPATH=C:\tensorflow1\models\research\slim

i'm already do like this but this appear

this = _pywrap_tensorflow_internal.new_CheckpointReader(filename) tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt: Not found: FindFirstFile failed for: C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28 : The system cannot find the path specified. ; No such process

anny solution?

Are you sure from the path (C:\tensorflow1\models\research\slim)?

ramapsam commented 4 years ago

set PYTHONPATH=C:\tensorflow1\models\research\slim

i'm already do like this but this appear this = _pywrap_tensorflow_internal.new_CheckpointReader(filename) tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt: Not found: FindFirstFile failed for: C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28 : The system cannot find the path specified. ; No such process anny solution?

Are you sure from the path (C:\tensorflow1\models\research\slim)?

yes exactly like this run this command set PYTHONPATH=C:\tensorflow1\models set PYTHONPATH=C:\tensorflow1\models\research set PYTHONPATH=C:\tensorflow1\models\research\slim

run the following commands from the C:\tensorflow1\models\research directory:

C:\tensorflow1\models\research> python setup.py build C:\tensorflow1\models\research> python setup.py install

after that i'm running this command python legacy/train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config and error appear

Mekatroniktr commented 4 years ago

run this command

set PYTHONPATH=C:\tensorflow1\models set PYTHONPATH=C:\tensorflow1\models\research set PYTHONPATH=C:\tensorflow1\models\research\slim !!! also> set PYTHONPATH=C:\tensorflow1\models\research\slim\net

run the following commands from the C:\tensorflow1\models\research directory:

C:\tensorflow1\models\research> python setup.py build C:\tensorflow1\models\research> python setup.py install

abumubaarak commented 4 years ago

The mistake I made was using setup.py instead of python setup.py

Rams901 commented 4 years ago

For those who had such an error: "could not create 'build':Cannot create a file when that file already exits" when trying to build the setup.py in the slim folder. You need to delete a file called 'BUILD" in the slim folder. and it will work.

olarapio commented 4 years ago

I solved this error by copying nets and deployment directories to the directory where train.py is

yajinwuzl commented 4 years ago

For those who had such an error: "could not create 'build':Cannot create a file when that file already exits" when trying to build the setup.py in the slim folder. You need to delete a file called 'BUILD" in the slim folder. and it will work. @Rams901 Your answer helped me!!!,thanks!

chiragpandav commented 4 years ago

if you are using Jupyter Notebook and using Linux sys

download tensorflow-models

and then write this in your Notebook

sys.path.append("/home/Roy/Downloads/models-master/research/slim/")

I solved my problem with this

hope it helps