I am new to object-detection-api, successfully installed the API,
the python object_detection_tutorial.ipynb
worked fine.
but when followed this tutorial, I get ValueError from tensorflow/python/module/module.py
through this tutorial, iv'e managed to do everything until the last step "trainnig model", than when i run this command:
python model_main.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
(All path's are correct) I get this error:
ValueError:
Constructing a tf.Module without calling the super constructor is not supported. Add the following as the first line in your __init__ method:
super(FasterRCNNMetaArch, self).__init__()
i haven't found any help with this, i have tried fresh installation of the object-detection-API, but didn't help.
I have got the same error, after this models/research/object_detection/g3doc/installation.md tutorial.
When trying to run:
python object_detection/builders/model_builder_test.py
I expected the model to start its traing, as in the tutorial.. but got this instead:
/home/gal/.virtualenvs/dl4cv/bin/python /home/gal/TensorFlow/models/research/object_detection/model_main.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
* https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.
W0610 17:22:52.758328 140705573046080 model_lib.py:615] Forced number of epochs for all eval validations to be 1.
I0610 17:22:52.758429 140705573046080 config_util.py:484] Maybe overwriting train_steps: None
I0610 17:22:52.758468 140705573046080 config_util.py:484] Maybe overwriting sample_1_of_n_eval_examples: 1
I0610 17:22:52.758504 140705573046080 config_util.py:484] Maybe overwriting use_bfloat16: False
I0610 17:22:52.758536 140705573046080 config_util.py:484] Maybe overwriting eval_num_epochs: 1
I0610 17:22:52.758566 140705573046080 config_util.py:484] Maybe overwriting load_pretrained: True
I0610 17:22:52.758595 140705573046080 config_util.py:494] Ignoring config override key: load_pretrained
W0610 17:22:52.758645 140705573046080 model_lib.py:631] Expected number of evaluation epochs is 1, but instead encountered `eval_on_train_input_config.num_epochs` = 0. Overwriting `num_epochs` to 1.
I0610 17:22:52.758683 140705573046080 model_lib.py:666] create_estimator_and_inputs: use_tpu False, export_to_tpu False
W0610 17:22:52.758958 140705573046080 estimator.py:1758] Using temporary folder as model directory: /tmp/tmp1lw9am0f
I0610 17:22:52.759102 140705573046080 estimator.py:202] Using config: {'_model_dir': '/tmp/tmp1lw9am0f', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': allow_soft_placement: true
graph_options {
rewrite_options {
meta_optimizer_iterations: ONE
}
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7ff8060b5f28>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
W0610 17:22:52.759208 140705573046080 estimator.py:1931] Estimator's model_fn (<function create_model_fn.<locals>.model_fn at 0x7ff8060c6158>) includes params argument, but params are not passed to Estimator.
I0610 17:22:52.759698 140705573046080 estimator_training.py:186] Not using Distribute Coordinator.
I0610 17:22:52.759793 140705573046080 training.py:612] Running training and evaluation locally (non-distributed).
I0610 17:22:52.759924 140705573046080 training.py:700] Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps None or save_checkpoints_secs 600.
W0610 17:22:52.763085 140705573046080 deprecation.py:323] From /home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow/python/training/training_util.py:238: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
Traceback (most recent call last):
File "/home/gal/TensorFlow/models/research/object_detection/model_main.py", line 109, in <module>
tf.app.run(main)
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "/home/gal/TensorFlow/models/research/object_detection/model_main.py", line 105, in main
tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 473, in train_and_evaluate
return executor.run()
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 613, in run
return self.run_local()
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 714, in run_local
saving_listeners=saving_listeners)
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 359, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1132, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1159, in _train_model_default
input_fn, ModeKeys.TRAIN))
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1000, in _get_features_and_labels_from_input_fn
self._call_input_fn(input_fn, mode))
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1087, in _call_input_fn
return input_fn(**kwargs)
File "/home/gal/TensorFlow/models/research/object_detection/inputs.py", line 446, in _train_input_fn
params=params)
File "/home/gal/TensorFlow/models/research/object_detection/inputs.py", line 512, in train_input
model_config, is_training=True).preprocess
File "/home/gal/TensorFlow/models/research/object_detection/builders/model_builder.py", line 135, in build
add_summaries)
File "/home/gal/TensorFlow/models/research/object_detection/builders/model_builder.py", line 597, in _build_faster_rcnn_model
**common_kwargs)
File "/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow/python/module/module.py", line 109, in __call__
"super(%s, self).__init__()" % cls.__name__)
ValueError: Constructing a tf.Module without calling the super constructor is not supported. Add the following as the first line in your __init__ method:
super(FasterRCNNMetaArch, self).__init__()
After some digging in, i have found that in:
/TensorFlow/models/research/object_detection/meta_architectures/faster_rcnn_meta_arch.py
In line 466:
super(FasterRCNNMetaArch, self).__init__(num_classes=num_classes)
so maybe it is not that. After following some breakpoint iv'e foune that in line 97 (the 'finally') in:
/home/gal/.virtualenvs/dl4cv/lib/python3.6/site-packages/tensorflow/python/module/module.py
theres this part, that raising the ValueError:
finally:
# The base Module constructor enters the modules name scope before
# returning such that other functionality in the ctor happens within the
# modules name scope.
scope = getattr(module, "_ctor_name_scope", None)
exc_info = sys.exc_info()
if scope is None:
if exc_info[0] is None:
raise ValueError(
"Constructing a tf.Module without calling the super constructor "
"is not supported. Add the following as the first line in your "
"__init__ method:\n\n"
"super(%s, self).__init__()" % cls.__name__)
else:
scope.__exit__(*exc_info)
del module._ctor_name_scope
When i run, scope
is None
, and also exc_info[0]
is None.
Any idea? thanks
OK,
after consulting some friends, it is appear to be a python3/python2 bug, and not tensor-flow_object_detection_API bug....
I have switched to python 2.7 and the everything worked swell :)
So I dont know what the problem was, but I have worked around it.
Hope it helps to anyone. Cheers, Gal.