2

When I try training my train.py for object detection using the tensorflow/models repository using the code

python train.py --logtostderr --train_dir=training_dir/ --pipeline_config_path=training/faster_rcnn_inception_resnet_v2_atrous_pets.config

I am unable to run this command.

I have tried including all the files within object_detection as well tried to remove the object_detection. In the from statement, but it didn't work.

import functools
import json
import os
import tensorflow as tf

from object_detection.builders import dataset_builder
from object_detection.builders import graph_rewriter_builder
from object_detection.builders import model_builder
from object_detection.legacy import trainer
from object_detection.utils import config_util
Traceback (most recent call last):
  File "C:/Users/varsh/Documents/models/research/object_detection/train.py", line 49, in <module>
    from object_detection.builders import dataset_builder
ModuleNotFoundError: No module named 'object_detection'

1 Answer 1

1

I've managed to solve this problem in my system (windows 10). The solution is not very straight forward but:

1) First u need to clone Tensorflow Object Detection API repository https://github.com/tensorflow/models.

2) Follow the installation provided in https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

3) In the step 2, you are required to compile protobuf library, so download the protobuf compiler at https://github.com/google/protobuf/releases/latest (at the time of this writing (3.5.1), there's a bug in protoc which may or may not related to the Windows environment, my solution is use the protoc v 3.4.0) 4) Append the PYTHONPATH environment variable with the directory of /research/ and /research/slim (dont forget to add the PYTHONPATH to Path if you haven't done so.

5) No more ModuleNotFoundError: No module named 'object_detection'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.