Tensorflow Object Detection API no train.py file

11,195

Solution 1

in the newest merge the train and eval moved to legacy dir. You can go to a previous version if you work with a tutorial.

Solution 2

For some clarification, as aforementioned by Derek Chow, it seems the train and evaluation python scripts were recently (~6 days ago) moved into the 'legacy' directory. Assuming you wanted to continue using the old way..

If one was beginning training by calling:

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

One would know begin training by calling:

python legacy/train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config

Solution 3

You should refer to Running locally section on the tutorial page.

Here is the sample configuration:

#From the tensorflow/models/research/ directory
PIPELINE_CONFIG_PATH={path to pipeline config file}
MODEL_DIR={path to model directory}
NUM_TRAIN_STEPS=50000
NUM_EVAL_STEPS=2000
python object_detection/model_main.py \
    --pipeline_config_path=${PIPELINE_CONFIG_PATH} \
    --model_dir=${MODEL_DIR} \
    --num_train_steps=${NUM_TRAIN_STEPS} \
    --num_eval_steps=${NUM_EVAL_STEPS} \
    --alsologtostderr 

and to run tensorboard:

tensorboard --logdir=${MODEL_DIR}

Solution 4

You can use the legacy train and evaluation scripts, but we recommend using model_main.

Share:
11,195
Giacomo Bartoli
Author by

Giacomo Bartoli

9 years in software development industry. Fluent in Javascript, Node js, Typescript and Java. Good knowledge of Python and Machine Learning Frameworks (Tensorflow, PyTorch).

Updated on July 08, 2022

Comments

  • Giacomo Bartoli
    Giacomo Bartoli almost 2 years

    I've correctly installed Tensorflow Object Detection API according to the provided documentation. However, when I need to train my network there is no train.py file in the research/object_detection directory. Is there anything I can do to fix this?

    Link: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

  • Giacomo Bartoli
    Giacomo Bartoli almost 6 years
    are you saying that model_main.py does both train and evaluation? What if I would like to run them separately because I need to supervise the learning phase?
  • Giacomo Bartoli
    Giacomo Bartoli almost 6 years
    Thank you. The point is that I run the model_main new script but it seems that it does not show the loss on the console. Using the previous script (train.py) I could clearly see on the console something like: step n -- loss: 2.5312 step n+1 --loss: 2.5310
  • Giacomo Bartoli
    Giacomo Bartoli almost 6 years
    Is it normal that the new model_main script does not show the loss on the console? Or maybe there's something wrong in mt tf config?
  • Derek Chow
    Derek Chow almost 6 years
    You should see event files being generated by model_main. Visualize these in tensorboard to see the training loss.
  • Giacomo Bartoli
    Giacomo Bartoli almost 6 years
    That's true Derek, but tf events are generated not at each step. They are record every 50-70 steps. This is why print the loss value on the console is useful.
  • willSapgreen
    willSapgreen over 5 years
    Hello Derek, where can we modify to show loss value on the console as before when using model_main.py? Thank you and thank you, Giacomo, for asking this question.
  • Nahiyan
    Nahiyan over 4 years
    I have the same question about the loss, still waiting for anyone's answer.