AttributeError: density_prediction_cell_json - Почему не удается загрузить файл json? - PullRequest
0 голосов
/ 23 мая 2019

Я пытаюсь внедрить модель DeepLab в среду Tensorflow.Это репозиторий github: https://github.com/tensorflow/models/tree/master/research/deeplab Я использую Python 3.6.8 и ноутбук Jupyter.Теперь я столкнулся с проблемой, что я не могу запустить train.py.Я получаю AttributeError: density_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.')
...