Models: DELF: absl.flags._exceptions.DuplicateFlagError: The flag 'seed' is defined twice

Created on 3 Jul 2020  路  7Comments  路  Source: tensorflow/models

Prerequisites

  • I am using the latest TensorFlow Model Garden release and TensorFlow 2.
  • I am reporting the issue to the correct repository. ( research directory)
  • I checked to make sure that this issue has not already been filed.

I followed the instructuins for Delf instalaltion from the link:
https://github.com/tensorflow/models/blob/master/research/delf/INSTALL_INSTRUCTIONS.md

Then used the follwing instruction to train the model
https://github.com/tensorflow/models/blob/master/research/delf/delf/python/training/README.md

2. Describe the bug

Traceback (most recent call last):
File "models/research/delf/delf/python/training/train.py", line 50, in
flags.DEFINE_integer('seed', 0, 'Seed to training dataset.')
File "/opt/conda/lib/python3.7/site-packages/absl/flags/_defines.py", line 315, in DEFINE_integer
DEFINE(parser, name, default, help, flag_values, serializer, **args)
File "/opt/conda/lib/python3.7/site-packages/absl/flags/_defines.py", line 82, in DEFINE
flag_values, module_name)
File "/opt/conda/lib/python3.7/site-packages/absl/flags/_defines.py", line 104, in DEFINE_flag
fv[flag.name] = flag
File "/opt/conda/lib/python3.7/site-packages/absl/flags/_flagvalues.py", line 430, in __setitem__
raise _exceptions.DuplicateFlagError.from_flag(name, self)
absl.flags._exceptions.DuplicateFlagError: The flag 'seed' is defined twice. First from delf.python.training.build_image_dataset, Second from models/research/delf/delf/python/training/train.py. Description from first occurrence: (Optional) The seed to be used while shuffling the traindataset when generating the TRAIN and VALIDATION splits.Recommended for splits reproducibility purposes.

A clear and concise description of what the bug is.
first I executed the script python3 delf/python/training/build_image_dataset.py
then python3 delf/python/training/train.py
I think the flag is redefined in the second script and for that, there is flag duplicate

research bug

Most helpful comment

I removed the flag seed from the train.py which solved the problem for now. It is only a workaround

All 7 comments

I removed the flag seed from the train.py which solved the problem for now. It is only a workaround

Not sure how this error can happen. Were you running the two commands separately, from the shell? If so, I don't see how this conflict could occur.

Or one hypothesis is that you are reusing a python environment, eg colab / jupyter, then all definitions from the first script are still there once you run the second one.

That is right, it is happing when I am using Jupyter. thanks!

I have the same problem and i'm working from the shell

But removing the flag seed from the train.py also solves the problem!

I met the same problem. However, I did this in a terminal. I firstly run build_image_dataset.py and then run train.py.
I comment flag seed in train.py to solve this temporarily.

Same here, in a terminal, getting the error after running build_image_dataset.py, then train.py. Will hard code seed in train.py.

Was this page helpful?
0 / 5 - 0 ratings