将(冻结的)Tensorflow模型加载到内存中时出错

时间:2019-07-10 17:26:35

标签: python tensorflow machine-learning anaconda

我正在使用tensorflow对象检测API。我找不到任何解决方案。请帮助我。

我的代码是

MODEL_NAME = 'inference_graph'
PATH_TO_FROZEN_GRAPH = MODEL_NAME + '/frozen_inference_graph.pb'
PATH_TO_LABELS = 'training/labelmap.pbtxt'

detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')

显示错误

<ipython-input-10-d55b98fd5a78> in <module>
  3   od_graph_def = tf.GraphDef()
  4   with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
   ----> 5     serialized_graph = fid.read()
  6     od_graph_def.ParseFromString(serialized_graph)
  7     tf.import_graph_def(od_graph_def, name='')

 ~\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py in 
 read(self, n)
123       string if in string (regular) mode.
124     """
--> 125     self._preread_check()
126     with errors.raise_exception_on_not_ok_status() as status:
127       if n == -1:

~\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py in 
_preread_check(self)
 83       with errors.raise_exception_on_not_ok_status() as status:
 84         self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(
 ---> 85             compat.as_bytes(self.__name), 1024 * 512, status)
 86 
 87   def _prewrite_check(self):

~\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py 
in __exit__(self, type_arg, value_arg, traceback_arg)
526             None, None,
527             compat.as_text(c_api.TF_Message(self.status.status)),
--> 528             c_api.TF_GetCode(self.status.status))
529     # Delete the underlying status object from memory otherwise it 
stays alive
530     # as there is a reference to status from this from the traceback 
due to

NotFoundError: NewRandomAccessFile failed to Create/Open: 
inference_graph/frozen_inference_graph.pb : The system cannot find the 
path specified.
; No such process

文件目录位于inference_graph / frozen_inference_graph.pb中,但是为什么会发生此错误?

1 个答案:

答案 0 :(得分:0)

您的问题将分为两部分。第一部分将检测图像中的车牌,第二部分将识别车牌上的字符。您可以在Kaggle或UCI仓库等数据仓库上轻松在线找到这两种情况的数据集。 CNN模型将遍历汽车的图像,直到找到车牌。找到车牌后,模型将遍历该车牌以读取字符。

Stackoverflow不适用于此问题,因为我们无法在不了解您的数据集的情况下为您提供任何模型架构,因此请查看this之类的在线资源。