3
votes

I am trying to train an object detector using TensorFlow following the following tutorial: https://cloud.google.com/blog/products/gcp/training-an-object-detector-using-cloud-machine-learning-engine

The tutorial asks to use object_detection.train, however this has been moved to legacy so I've used object_detection.model_main instead. Line 21 of this python file calls the module absl, however this causes the following error (from the GCP Logs Viewer).

Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/model_main.py", line 21, in from absl import flags ImportError: No module named absl

I tried to include absl>=0.1 in the required packages section of the setup.py file for the object_detection package but that didn't work. Next I tried to move my absl folder into the models/research/object_detection directory before packaging and starting the job, but that didn't work either. How do I fix this? I'm very new to Tensorflow and the GCP platform so your help will be appreciated. Thanks.

1
You should be able to access flags through tf.app.flags without the absl package. If you replace each occurrence of flags (lowercase) with tf.app.flags, remove the absl import, and remove the lines containing flags.mark_flag_as_required, will the application work?MatthewScarpino
@MatthewScarpino Having to replace every single mention of a module in every single file is incredibly tedious. Code that actually works with the modules it claims to need is really ideal.user124384
@Tejas I have managed to overcome the error. The package that you should be adding to REQUIRED_PACKAGES list in setup.py is 'absl-py>=0.1.0'. Apart from that, download this package tar.gz file to models/research/dist . Install by running pip install absl-py . Then, when starting the job add dist/avsl-0.4.0.tar.gz to the variables passed to the --packages flag.Philipp Sh
@PhilippSh your solution works perfect. Why not add it to the answers?Pramesh Bajracharya

1 Answers

2
votes

The package that you should be adding to REQUIRED_PACKAGES list in setup.py is 'absl-py>=0.1.0'. Apart from that, download this package tar.gz file to models/research/dist . Install by running pip install absl-py . Then, when starting the job add dist/avsl-0.4.0.tar.gz to the variables passed to the --packages flag.