TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 icon indicating copy to clipboard operation
TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 copied to clipboard

Are you planning to try "model_main.py" again instead of "train.py"

Open anonym24 opened this issue 8 years ago • 14 comments

I suppose "model_main.py" should work better and mb then even fixed some errors which can affect speed/accuracy of models

anonym24 avatar Nov 06 '18 08:11 anonym24

I see model_main.py needs cocoapi (pycocotools)

For Windows we can install it from https://github.com/philferriere/cocoapi

anonym24 avatar Nov 08 '18 07:11 anonym24

but it fails with next errors TypeError: can't pickle dict_values objects

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

anonym24 avatar Nov 08 '18 08:11 anonym24

Seems this error can be solved by https://github.com/guildai/models/commit/d88f1fb9cad472c38149f208b086ca90c1da0856 https://github.com/tensorflow/models/issues/4780#issuecomment-405441448

anonym24 avatar Nov 08 '18 08:11 anonym24

seems it finally started to work with model_train.py

I start train like this (# From the tensorflow/models/research/ directory)

python object_detection\model_main.py --pipeline_config_path=object_detection\training\ssd_mobilenet_v1_pets.config --model_dir=object_detection\images --num_train_steps=50000 --sample_1_of_n_eval_examples=1 --alsologtostderr

(more info: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_locally.md)

I see some checkpoints:

image

Though output of console isn't that useful: https://github.com/tensorflow/models/issues/5719#issuecomment-436927568

anonym24 avatar Nov 08 '18 09:11 anonym24

Solved and it works ok after some configuration: https://github.com/tensorflow/models/issues/5719#issuecomment-437323963

So SSD Models can be train normally with model_train.py (works on Windows and Ubuntu), with legacy train.py you can get OOM errors

anonym24 avatar Nov 09 '18 13:11 anonym24

also by default model_train.py doesn't print any logs in your console

here'e a solution to fix it:

add tf.logging.set_verbosity(tf.logging.INFO) line after imports in model_train.py

image

image

anonym24 avatar Nov 12 '18 09:11 anonym24

@anonym24 How is model_main.py different from train.py?

dscha09 avatar Jan 08 '19 01:01 dscha09

where is this model_train.py file?

JanithT-Lboro avatar Jan 25 '19 18:01 JanithT-Lboro

@dscha09 I don't know but with legacy train.py you can get OOM errors while starting training and at some point of training

@JanithT-Lboro https://github.com/tensorflow/models/blob/master/research/object_detection/model_main.py

anonym24 avatar Jan 31 '19 12:01 anonym24

I was able to solve this problem by just using a PC with better specs.

JanithT-Lboro avatar Feb 01 '19 15:02 JanithT-Lboro

C:\tensorflow\models\research>python object_detection\model_main.py --pipeline_config_path=object_detection\training\ssd_mobilenet_v1_pets.config --model_dir=object_detection\images --num_train_steps=50000 --sample_1_of_n_eval_examples=1 --alsologtostderr Traceback (most recent call last): File "object_detection\model_main.py", line 26, in from object_detection import model_lib File "C:\Users\Fuat\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detection\model_lib.py", line 27, in from object_detection import eval_util File "C:\Users\Fuat\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detection\eval_util.py", line 27, in from object_detection.metrics import coco_evaluation File "C:\Users\Fuat\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detection\metrics\coco_evaluation.py", line 22, in from object_detection.utils import object_detection_evaluation File "C:\Users\Fuat\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detection\utils\object_detection_evaluation.py", line 39, in from object_detection.utils import label_map_util File "C:\Users\Fuat\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detection\utils\label_map_util.py", line 21, in from object_detection.protos import string_int_label_map_pb2 ImportError: cannot import name 'string_int_label_map_pb2'

I got this error.How can i fix it.I installed protobuf, compiled it, added to path. OS:Windows 10 CPU:AMD A9 7th Gen. Python version:3.6 Protobuf version:3.4.0

Futi7 avatar Feb 03 '19 21:02 Futi7

@Futi7 I'm not sure on windows but I think you can solve it by running protoc object_detection/protos/*.proto --python_out=.

dienhoa avatar Feb 07 '19 21:02 dienhoa

this work great

johnneijzen avatar Feb 08 '19 06:02 johnneijzen

Hey @anonym24 , I know it's been a year, but thanks for your work on this issue! I'm still considering whether to update my guide to use model_main.py rather than train.py. It's a bummer that it doesn't log training information in the console by default.

This issue (TensorFlow #6100) has some good information directly from a TensorFlow team member on the differences between train.py and model_main.py. From their comments, it sounds like there is no difference when using a normal PC for training.

EdjeElectronics avatar Sep 21 '19 15:09 EdjeElectronics