我使用TensorFlow对象检测API运行SSD MobileNetV2,运行以下代码后
(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
我收到了错误
TypeError:pred
必须是Tensor,或Python bool,或1或0.发现:无
(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
我下载更新的Object Detection API时遇到此错误,但之前的版本使用SSD MobileNetV1成功运行。有没有人遇到过这种错误?提前谢谢!
答案 0 :(得分:7)
我们正在寻找合适的解决方案。同时,请将this file中的第109行从is_training=None
更改为is_training=True
。此解决方法应该通过MobileNetV2培训。