How to run tensorflow object detection api (model_main_tf2) from code?
I want to run a training with the tensorflow object detection api. In the command line I can use the
python model_main_tf2.py --pipeline_config_path=path/to/pipeline.config --model_dir=path/to/trainedModel
But how can I start it from code?
model_main_tf2.FLAGS.pipeline_config_path = pipeline_config_path model_main_tf2.FLAGS.model_dir = model_path tf.compat.v1.app.run(model_main_tf2.main)
This is working, but the tf.compat.v1.app.run() calls the main function by using sys.exit(main). However I do not want, that the system exits.
How can I solve this?
Or maybe, how can I get around the usage of model_main_tf2 and the app.run()?
sys.exit(...) basically raises
SystemExit you may just catch the
try: tf.compat.v1.app.run(model_main_tf2.main) except SystemExit: pass # cool stuff happening here!
Answered By – Franz Diebold