如何解决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 举报,一经查实,本站将立刻删除。