13

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
  • 730
  • 3
  • 9
  • 23

4 Answers4

8

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
DSmith
  • 159
  • 1
  • 1
  • 13
  • 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 Jul 18 '18 at 18:29
6

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}
g_p
  • 5,499
  • 3
  • 19
  • 22
  • 2
    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 Jul 18 '18 at 16:56
4

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.

3

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

Derek Chow
  • 722
  • 3
  • 6
  • 1
    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? – Giacomo Bartoli Jul 18 '18 at 18:30
  • You should see event files being generated by model_main. Visualize these in tensorboard to see the training loss. – Derek Chow Jul 19 '18 at 17:30
  • 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. – Giacomo Bartoli Jul 19 '18 at 20:44
  • 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. – willSapgreen Jul 30 '18 at 22:35
  • I have the same question about the loss, still waiting for anyone's answer. – Nahiyan Aug 12 '19 at 17:33