TypeError: `pred` must be a Tensor, or a Python bool, or 1 or 0. Found instead: None
Asked Answered
M

1

5

I am running an SSD MobileNetV2 using TensorFlow Object Detection API, After running the following code

(keras-cpu-exp) D:\Pycharm Projects\CPU\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v2_coco.config

I got the error

TypeError: pred must be a Tensor, or a Python bool, or 1 or 0. Found instead: None

(keras-cpu-exp) D:\Pycharm Projects\CPU\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v2_coco.config
C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\h5py\__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
WARNING:tensorflow:From C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use the retry module or similar alternatives.
Traceback (most recent call last):
  File "train.py", line 167, in <module>
    tf.app.run()
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run
    _sys.exit(main(argv))
  File "train.py", line 92, in main
    FLAGS.pipeline_config_path)
  File "D:\Pycharm Projects\CPU\models\research\object_detection\utils\config_util.py", line 93, in get_configs_from_pipeline_file
    text_format.Merge(proto_str, pipeline_config)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 533, in Merge
    descriptor_pool=descriptor_pool)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 587, in MergeLines
    return parser.MergeLines(lines, message)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 620, in MergeLines
    self._ParseOrMerge(lines, message)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 635, in _ParseOrMerge
    self._MergeField(tokenizer, message)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 735, in _MergeField
    merger(tokenizer, message, field)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 823, in _MergeMessageField
    self._MergeField(tokenizer, sub_message)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 735, in _MergeField
    merger(tokenizer, message, field)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 823, in _MergeMessageField
    self._MergeField(tokenizer, sub_message)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 735, in _MergeField
    merger(tokenizer, message, field)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 823, in _MergeMessageField
    self._MergeField(tokenizer, sub_message)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\google\protobuf\text_format.py", line 703, in _MergeField
    (message_descriptor.full_name, name))
google.protobuf.text_format.ParseError: 108:7 : Message type "object_detection.protos.SsdFeatureExtractor" has no field named "batch_norm_trainable".

(keras-cpu-exp) D:\Pycharm Projects\CPU\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v2_coco.config
C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\h5py\__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
WARNING:tensorflow:From C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use the retry module or similar alternatives.
WARNING:tensorflow:From D:\Pycharm Projects\CPU\models\research\object_detection\trainer.py:257: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
Failed to create op 0: Op(op=<function add_arg_scope.<locals>.func_with_args at 0x000002DA5411ED90>, params={'stride': 2, 'num_outputs': 32, 'kernel_size': [3, 3]}, multiplier_func=<function add_arg_scope.<locals>.func_with_args at 0x000002DA56D49A60>) params: {'stride': 2, 'num_outputs': 32, 'kernel_size': [3, 3]}
Traceback (most recent call last):
  File "train.py", line 167, in <module>
    tf.app.run()
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run
    _sys.exit(main(argv))
  File "train.py", line 163, in main
    worker_job_name, is_chief, FLAGS.train_dir)
  File "D:\Pycharm Projects\CPU\models\research\object_detection\trainer.py", line 275, in train
    clones = model_deploy.create_clones(deploy_config, model_fn, [input_queue])
  File "D:\Pycharm Projects\CPU\models\research\slim\deployment\model_deploy.py", line 193, in create_clones
    outputs = model_fn(*args, **kwargs)
  File "D:\Pycharm Projects\CPU\models\research\object_detection\trainer.py", line 198, in _create_losses
    prediction_dict = detection_model.predict(images, true_image_shapes)
  File "D:\Pycharm Projects\CPU\models\research\object_detection\meta_architectures\ssd_meta_arch.py", line 384, in predict
    preprocessed_inputs)
  File "D:\Pycharm Projects\CPU\models\research\object_detection\models\ssd_mobilenet_v2_feature_extractor.py", line 123, in extract_features
    scope=scope)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 183, in func_with_args
    return func(*args, **current_args)
  File "D:\Pycharm Projects\CPU\models\research\slim\nets\mobilenet\mobilenet_v2.py", line 162, in mobilenet_base
    base_only=True, **kwargs)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 183, in func_with_args
    return func(*args, **current_args)
  File "D:\Pycharm Projects\CPU\models\research\slim\nets\mobilenet\mobilenet_v2.py", line 154, in mobilenet
    **kwargs)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 183, in func_with_args
    return func(*args, **current_args)
  File "D:\Pycharm Projects\CPU\models\research\slim\nets\mobilenet\mobilenet.py", line 325, in mobilenet
    net, end_points = mobilenet_base(inputs, scope=scope, **mobilenet_args)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 183, in func_with_args
    return func(*args, **current_args)
  File "D:\Pycharm Projects\CPU\models\research\slim\nets\mobilenet\mobilenet.py", line 244, in mobilenet_base
    net = opdef.op(net, **params)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 183, in func_with_args
    return func(*args, **current_args)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 1058, in convolution
    outputs = normalizer_fn(outputs, **normalizer_params)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 183, in func_with_args
    return func(*args, **current_args)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 650, in batch_norm
    outputs = layer.apply(inputs, training=is_training)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\python\layers\base.py", line 825, in apply
    return self.__call__(inputs, *args, **kwargs)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\python\layers\base.py", line 714, in __call__
    outputs = self.call(inputs, *args, **kwargs)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\python\layers\normalization.py", line 549, in call
    training_value = utils.constant_value(training)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\python\layers\utils.py", line 232, in constant_value
    return smart_module.smart_constant_value(pred)
  File "C:\Users\Reagan\AppData\Local\Continuum\Anaconda3\envs\keras-cpu-exp\lib\site-packages\tensorflow\python\framework\smart_cond.py", line 93, in smart_constant_value
    "Found instead: %s" % pred)
TypeError: `pred` must be a Tensor, or a Python bool, or 1 or 0. Found instead: None

I encountered this error when I downloaded the updated Object Detection API, but the previous version runs successfully using SSD MobileNetV1. Did anyone encounter this kind of error? Thank you in advance!

Medullated answered 18/4, 2018 at 3:44 Comment(0)
R
7

We're looking for a proper fix. In the mean time, please change line 109 in this file from is_training=None to is_training=True. This workaround should get MobileNetV2 training.

Reparative answered 18/4, 2018 at 6:26 Comment(2)
But throws a warning like this, WARNING:root:Variable [FeatureExtractor/MobilenetV2/Conv/BatchNorm/beta/ExponentialMovingAverage] is not available in checkpointMedullated
work for me too but we need to know why we have to change this value...Thermocline

© 2022 - 2024 — McMap. All rights reserved.