Tensorflow冻结protobuf文件检查点文件不存在

时间:2018-06-14 21:20:06

标签: android python tensorflow protocol-buffers tensorflow-lite

我正在使用此演示中的retrain.python文件。 我得到了不同类型的文件:

enter image description here

enter image description here

enter image description here

我想使用检查点文件冻结graph.pb,以优化冻结文件,然后将优化文件转换为tflite文件,以便在Android应用程序中使用它。

我尝试了不同的方法来冻结文件,但没有运气,

  

终端

中不存在检查点文件

  

UnicodeDecodeError:'utf-8'编解码器无法解码字节0x86   1:无效的起始字节

如何完成所有步骤并获取tflite文件以及如何组合labels.txt文件?

注意: 这是我在终端中使用的命令:

python freeze_graph.py \ 
--input_graph=/home/automator/Desktop/retrain/code/graph/graph.pb \ 
--input_checkpoint=/home/automator/Desktop/retrain/code/tmp/model.ckpt \ 
--output_graph=/home/automator/Desktop/retrain/code/frozen.pb \ 
--output_node_names=output_node \
--input_saved_model_dir=/home/automator/Desktop/retrain/code/export/frozen.pb \ --output_node_names=outInput 

错误: 检查点''不存在!

尝试:

--input_checkpoint=/home/automator/Desktop/retrain/code/tmp/model.ckpt
--input_checkpoint=/home/automator/Desktop/retrain/code/tmp/model
--input_checkpoint=/home/automator/Desktop/retrain/code/tmp/modelmodel.ckpt
....

请帮忙!

2 个答案:

答案 0 :(得分:2)

这是一个很好的冻结图形的脚本

    		<!-- Web Fonts -->
    		<link href='http://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic,500,700,900,500italic' rel='stylesheet' type='text/css'>
    		
    	<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/>
    		<!-- Main CSS -->
    		<link rel="stylesheet" href="services/css/style.css" />
    			

	
   


        <div class="container-fluid" style="background-color: white;">
         <div class="row">
        <div class="col-md-4 col-sm-4 col-xs-12" style="margin-bottom: 100px; margin-top: 100px" >
          <h1>My First Bootstrap Page</h1>      
          <p>This part is inside a .container-fluid class.</p> 
          <p>The .container-fluid class provides a full width container, spanning the entire width of the viewport.</p>   
          </div>
          
        
        <div class="col-md-4 col-sm-4 col-xs-16" style="margin-bottom: 100px; margin-top: 100px"  >
          <div class="service-box">
        			<span class="icon-rounded flaticon-business70"></span>
        
        				<h2 class="service-title"><a href="services-single.html">Information Design</a></h2>
        
        				<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit sed rhoncus ex condimentum. Donec placerat nunc ut porttitor blandit. Duis ex nisi, tristique nec nullaf non.</p>
        
        				<a class="btn btn-primary" href="services-single.html">Read More <i class="fa fa-long-arrow-right"></i></a>
        						</div>  
          </div>
          
        <div class="col-md-4 col-sm-4 col-xs-16" style="margin-bottom: 100px; margin-top: 100px">
          <h1>My First Bootstrap Page</h1>      
          <p>This part is inside a .container-fluid class.</p> 
          <p>The .container-fluid class provides a full width container, spanning the entire width of the viewport.</p>   
          </div>
          
          </div>
        </div>

将其另存为freeze_graph.py

称之为: python freeze_graph.py /home/automator/Desktop/retrain/code/tmp/model.data-000000-of-00001" output_node_name&#34;

答案 1 :(得分:0)

鉴于您已保存meta graph,请尝试使用input_meta_graph参数:

python freeze_graph.py \ 
--input_meta_graph=/home/automator/Desktop/retrain/code/tmp/model.meta \ 
--input_checkpoint=/home/automator/Desktop/retrain/code/tmp/model.ckpt \ 
--input_binary=true \
--output_graph=/home/automator/Desktop/retrain/code/frozen.pb \ 
--output_node_names=output_node 

问题是您传递的--input_saved_model_dir参数overwrites input_meta_graph参数,但您似乎没有SavedModel