tensorflow导出冻结图模型

本文介绍了如何在TensorFlow中导出推理图,冻结模型文件,并详细阐述了使用冻结模型的过程,以便于在web上进行服务。通过这个过程,可以确保模型在部署时保持静态,提高效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

导出推理图

python export_inference_graph.py \
  --alsologtostderr \
  --dataset_name=autohome \  #自定义数据集的名称
  --model_name=mobilenet_v2_140 \ #模型名字
  --image_size=224 \
  --output_file=angle/mobilenet_v2_140_224_inference.pb #待输出的推理图

冻结模型文件

python -m tensorflow.python.tools.freeze_graph \
   --input_graph=angle/mobilenet_v2_140_224_inference.pb \ #推理图
   --input_binary=true \
   --output_node_names=MobilenetV2/Predictions/Reshape_1 \ #根据不同模型确定各自的输出节点
   --input_checkpoint=angle/model/model.ckpt-10560 \  #训练的模型文件
   --output_graph=angle/model/frozen_angle8.pb   #导出的冻结图

使用冻结模型

import tensorflow as tf
import os
import numpy as np
import os, glob, cv2
import sys, argparse

# First, pass the path of the image
dir_path = os.path.dirname(os.path.realpath(__file__))
image_path = sys.argv[1]
filename = dir_path + '/' + image_path
image_size = 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值