tensorflow v1.15错误export_inference_graph.py

问题描述

系统信息

  • 操作系统平台:Windows 10
  • 从anaconda安装的TensorFlow:
  • TensorFlow版本:1.15
  • Python版本:python 3.7.0
  • GPU:我尝试在Google colab和计算机上安装GPU

执行命令

python export_inference_graph.py --input_type=image_tensor --pipeline_config_path=training/ssd_mobilenet_v1_pets.config --trained_checkpoint_prefix=training/model.ckpt-104 --output_directory=new

错误

Traceback (most recent call last):
  File "export_inference_graph.py",line 160,in <module>
    tf.app.run()
  File "C:\Users\perezab\Anaconda3\envs\object-detection\lib\site-packages\tensorflow_core\python\platform\app.py",line 40,in run
    _run(main=main,argv=argv,flags_parser=_parse_flags_tolerate_undef)
  File "C:\Users\perezab\Anaconda3\envs\object-detection\lib\site-packages\absl\app.py",line 300,in run
    _run_main(main,args)
  File "C:\Users\perezab\Anaconda3\envs\object-detection\lib\site-packages\absl\app.py",line 251,in _run_main
    sys.exit(main(argv))
  File "export_inference_graph.py",line 156,in main
    f.write(graph_def.SerializetoString())
  File "C:\Users\perezab\Anaconda3\envs\object-detection\lib\site-packages\tensorflow_core\python\lib\io\file_io.py",line 106,in write
    self._prewrite_check()
  File "C:\Users\perezab\Anaconda3\envs\object-detection\lib\site-packages\tensorflow_core\python\lib\io\file_io.py",line 92,in _prewrite_check
    compat.as_bytes(self.__name),compat.as_bytes(self.__mode))
tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a NewWriteableFile:  : The system cannot find the path specified.
; No such process

我正在使用以下链接中的export_inference_graph.py https://github.com/tensorflow/models/tree/master/research/object_detection

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os

import tensorflow.compat.v1 as tf
from tensorflow.contrib import quantize as contrib_quantize


from tensorflow.python.platform import gfile
from datasets import dataset_factory
from nets import nets_factory


tf.app.flags.DEFINE_string(
    'model_name','inception_v3','The name of the architecture to save.')

tf.app.flags.DEFINE_boolean(
    'is_training',False,'Whether to save out a training-focused version of the model.')

tf.app.flags.DEFINE_integer(
    'image_size',None,'The image size to use,otherwise use the model default_image_size.')

tf.app.flags.DEFINE_integer(
    'batch_size','Batch size for the exported model. Defaulted to "None" so batch size can '
    'be specified at model runtime.')

tf.app.flags.DEFINE_string('dataset_name','imagenet','The name of the dataset to use with the model.')

tf.app.flags.DEFINE_integer(
    'labels_offset','An offset for the labels in the dataset. This flag is primarily used to '
    'evaluate the VGG and resnet architectures which do not use a background '
    'class for the ImageNet dataset.')

tf.app.flags.DEFINE_string(
    'output_file','','Where to save the resulting file to.')

tf.app.flags.DEFINE_string(
    'dataset_dir','Directory to save intermediate dataset files to')

tf.app.flags.DEFINE_bool(
    'quantize','whether to use quantized graph or not.')

tf.app.flags.DEFINE_bool(
    'is_video_model','whether to use 5-D inputs for video model.')

tf.app.flags.DEFINE_integer(
    'num_frames','The number of frames to use. Only used if is_video_model is True.')

tf.app.flags.DEFINE_bool('write_text_graphdef','Whether to write a text version of graphdef.')

tf.app.flags.DEFINE_bool('use_grayscale','Whether to convert input images to grayscale.')

FLAGS = tf.app.flags.FLAGS


def main(_):
  if FLAGS.is_video_model and not FLAGS.num_frames:
    raise ValueError(
        'Number of frames must be specified for video models with --num_frames')
  tf.logging.set_verbosity(tf.logging.INFO)
  with tf.Graph().as_default() as graph:
    dataset = dataset_factory.get_dataset(FLAGS.dataset_name,'train',FLAGS.dataset_dir)
    network_fn = nets_factory.get_network_fn(
        FLAGS.model_name,num_classes=(dataset.num_classes - FLAGS.labels_offset),is_training=FLAGS.is_training)
    image_size = FLAGS.image_size or network_fn.default_image_size
    num_channels = 1 if FLAGS.use_grayscale else 3
    if FLAGS.is_video_model:
      input_shape = [
          FLAGS.batch_size,FLAGS.num_frames,image_size,num_channels
      ]
    else:
      input_shape = [FLAGS.batch_size,num_channels]
    placeholder = tf.placeholder(name='input',dtype=tf.float32,shape=input_shape)
    network_fn(placeholder)

    if FLAGS.quantize:
      contrib_quantize.create_eval_graph()

    graph_def = graph.as_graph_def()
    if FLAGS.write_text_graphdef:
      tf.io.write_graph(
          graph_def,os.path.dirname(FLAGS.output_file),os.path.basename(FLAGS.output_file),as_text=True)
    else:
      with gfile.GFile(FLAGS.output_file,'wb') as f:
        f.write(graph_def.SerializetoString())


if __name__ == '__main__':
  tf.app.run()

我已经拥有#104检查站 Checkpoint

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...