Tensorflow lite模型转换过

本文详细介绍如何使用TensorFlow Lite将预训练的SSD MobileNet V2模型转换为适用于移动设备的格式。从下载官方模型开始,通过特定的Python脚本进行模型转换,最后利用tflite_convert工具生成tflite模型文件。

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

tensorflow lite是专门为移动设备准备的深度学习架构,在tensorflow基础上优化并支持手机上的硬件加速

首先下载如下网址链接

git clone https://github.com/tensorflow/models.git
  • 下载官方训练好的模型
  • (e.g., cd …/ssdlite_mobilenet_v2_coco_2018_05_09)
  • 执行一下代码进行转换
 python3 ./models/research/object_detection/export_tflite_ssd_graph.py --pipeline_config_path /home/rui/model_dir/ssd_mobilenet_v2_coco.config --trained_checkpoint_prefix /home/rui/model_dir/model.ckpt-122712 --output_directory /home/rui/model_dir/ --add_postprocessing_op True
  • 转化完毕后,使用一下代码进行转换
tflite_convert --graph_def_file=/home/rui/model_dir/tflite_graph.pb --output_file=/home/rui/model_dir/detect.tflite --input_shapes=1,300,300,3 --input_arrays=normalized_input_image_tensor --output_arrays=TFLite_Detection_PostProcess,TFLite_Detection_PostProcess:1,TFLite_Detection_PostProcess:2,TFLite_Detection_PostProcess:3 --allow_custom_ops

成功后将生成的模型文件放入android sset目录下即可,并改成相应名称。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值