Models: AttributeError: module 'tensorflow.python.platform.flags' has no attribute 'mark_flag_as_required'

Created on 13 Nov 2017  路  11Comments  路  Source: tensorflow/models

System information

  • What is the top-level directory of the model you are using:
    ~/tensorflow/models/research/object_detection
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No. Only slightly modified the config file of the model I am trying to work with.
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04
  • TensorFlow installed from (source or binary): Binary
  • TensorFlow version (use command below): v1.2.1-0-gb4957ff' 1.2.1
  • CUDA/cuDNN version: CUDA 8.0, cudnn 6.0, nVidia driver: 375.66
  • GPU model and memory: AWS p2 instance. So NVIDIA Tesla K80 Accelerators and 12 GB
  • Exact command to reproduce:
    > python export_inference_graph.py --input_type image_tensor --pipeline_config_path pipeline.config --trained_checkpoint_prefix models/train/model.ckpt-250 --output_directory fine_tuned_model

Describe the problem

Upon running the command above, I get the following error.

AttributeError: module 'tensorflow.python.platform.flags' has no attribute 'mark_flag_as_required'

And I haven't been able to identify the problem anywhere online.

Source code / logs

Traceback

Traceback (most recent call last):
File "export_inference_graph.py", line 96, in
tf.app.flags.mark_flag_as_required('pipeline_config_path')
AttributeError: module 'tensorflow.python.platform.flags' has no attribute 'mark_flag_as_required'

community support

Most helpful comment

@shivaniag @tombstone So, it won't be fixed for any of the recent prior versions, like 1.3?

All 11 comments

Found out that only TF 1.4 has that particular attribute and not any versions before that. (Tried the above with 1.3 as well and doesn't work. https://github.com/tensorflow/tensorflow/blob/r1.4/tensorflow/python/platform/flags.py

Will 1.3 be updated as well for the Object Detection API? Could be an issue for the project I am working on 馃槥

I have the same problem, have you managed to solve this?

I had the same error, commenting out lines 96-98 starting with tf.app.flags.mark_flag_as_required in export_inference_graph.py seemed to worked for me. Will this have affected the exported model in someway? From what I can tell it hasn't.

I don't think you can just commented it out as those params specify important paths. You can roll back to previous version of that file but you will get other errors such as:

TypeError: x and y must have the same dtype, got tf.float32 != tf.int32

@mpeniak thats what I thought, but it seemed to work fine for me? Lines 77 - 94 define all the input params. I am guessing tf.app.flags.mark_flag_as_required is just there to throw an error if you have not given all the input params? Seems odd as well they use the full name tf.apps.flags.<> instead of flags.<>, I know its the same but makes me think it shouldn't be there.

I also simply commented out the lines and it seems to work. Don't understand why the authors chose to validate in a breaking way.

I copied the flags.py script from the 1.4v repo and pasted it instead of the flags.py in my local installation of 1.3v. It's working so far for me.

An alternative would be to work with TF 1.4v directly.

I have the same problem,prepare to install 1.4v and try again.

Closing this issue since it seems to be working in v1.4, feel free to reopen if it doesn't solve the problem.

@shivaniag @tombstone So, it won't be fixed for any of the recent prior versions, like 1.3?

Traceback (most recent call last):
File "DeepSpeech.py", line 11, in
import absl.app
File "/home/sehar/venv/lib/python3.6/site-packages/absl/app.py", line 40, in
from absl import flags
File "/home/sehar/venv/lib/python3.6/site-packages/absl/flags/__init__.py", line 41, in
from absl.flags import _defines
File "/home/sehar/venv/lib/python3.6/site-packages/absl/flags/_defines.py", line 31, in
from absl.flags import _flagvalues
File "/home/sehar/venv/lib/python3.6/site-packages/absl/flags/_flagvalues.py", line 27, in
import logging
File "/home/sehar/DeepSpeech/logging.py", line 6, in
from util.flags import FLAGS
File "/home/sehar/DeepSpeech/util/flags.py", line 6, in
FLAGS = absl.flags.FLAGS
AttributeError: module 'absl' has no attribute 'flags'
kindly help me to slove this error

Was this page helpful?
0 / 5 - 0 ratings