AttributeError:density_prediction_cell_json-为什么无法加载json文件?

时间:2019-05-23 11:41:19

标签: python tensorflow attributeerror deeplab

我正在尝试在Tensorflow环境中实现DeepLab模型。 这是github存储库:https://github.com/tensorflow/models/tree/master/research/deeplab 我正在使用Python 3.6.8和Jupyter Notebook。 现在,我面临着无法运行train.py的问题。我收到了AttributeError:deny_prediction_cell_json,但我不明白为什么。

我试图更改代码以使路径正确进入变量。每次一样的错误。 .json文件位于正确的存储库中。

AttributeError                            Traceback (most recent call last)
<ipython-input-10-82da774ae9f4> in <module>
      2   flags.mark_flag_as_required('train_logdir')
      3   flags.mark_flag_as_required('dataset_dir')
----> 4   tf.app.run()

~\Anaconda\Anaconda3\envs\Tensorflow-GPU\lib\site-packages\tensorflow\python\platform\app.py in run(main, argv)
    123   # Call the main function, passing through any arguments
    124   # to the final program.
--> 125   _sys.exit(main(argv))
    126 

<ipython-input-9-5ba5cfdf622b> in main(unused_argv)
     32       train_tensor, summary_op = _train_deeplab_model(
     33           dataset.get_one_shot_iterator(), dataset.num_of_classes,
---> 34           dataset.ignore_label)
     35 
     36       # Soft placement allows placing on CPU ops without GPU implementation.

<ipython-input-8-75f72f4530ec> in _train_deeplab_model(iterator, num_of_classes, ignore_label)
     34             ignore_label=ignore_label,
     35             scope=scope,
---> 36             reuse_variable=(i != 0))
     37         tower_losses.append(loss)
     38 

<ipython-input-5-a0f1ad776056> in _tower_loss(iterator, num_of_classes, ignore_label, scope, reuse_variable)
     14   with tf.variable_scope(
     15       tf.get_variable_scope(), reuse=True if reuse_variable else None):
---> 16     _build_deeplab(iterator, {common.OUTPUT_TYPE: num_of_classes}, ignore_label)
     17 
     18   losses = tf.losses.get_losses(scope=scope)

<ipython-input-4-54ae914e10d7> in _build_deeplab(iterator, outputs_to_num_classes, ignore_label)
     19       crop_size=[int(sz) for sz in FLAGS.train_crop_size],
     20       atrous_rates=FLAGS.atrous_rates,
---> 21       output_stride=FLAGS.output_stride)
     22 
     23   outputs_to_scales_to_logits = model.multi_scale_logits(

~\Anaconda\DeepLab\models\research\deeplab\common.py in __new__(cls, outputs_to_num_classes, crop_size, atrous_rates, output_stride, preprocessed_images_dtype)
    190 
    191     dense_prediction_cell_config = None
--> 192     if FLAGS.dense_prediction_cell_json:
    193       with tf.gfile.Open(FLAGS.dense_prediction_cell_json, 'r') as f:
    194             dense_prediction_cell_config = json.load(f)

~\Anaconda\Anaconda3\envs\Tensorflow-GPU\lib\site-packages\tensorflow\python\platform\flags.py in __getattr__(self, name)
     83     if not wrapped.is_parsed():
     84       wrapped(_sys.argv)
---> 85     return wrapped.__getattr__(name)
     86 
     87   def __setattr__(self, name, value):

~\Anaconda\Anaconda3\envs\Tensorflow-GPU\lib\site-packages\absl\flags\_flagvalues.py in __getattr__(self, name)
    471     fl = self._flags()
    472     if name not in fl:
--> 473       raise AttributeError(name)
    474     if name in self.__dict__['__hiddenflags']:
    475       raise AttributeError(name)

AttributeError: dense_prediction_cell_json

在common.py文件中,标志定义为:

flags.DEFINE_string(
    'dense_prediction_cell_json',
    './core/dense_prediction_cell_branch5_top1_cityscapes.json',
    'A JSON file that specifies the dense prediction cell.')

0 个答案:

没有答案