tensorflow ssdlite压缩模型transform

本文介绍如何使用TensorFlow将SSDLite模型转换为TFLite格式,包括量化和浮点两种类型,并提供了详细的命令行操作步骤。

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

  1. 下载最新的TensorFlow  
  2. git clone https://github.com/tensorflow/tensorflow.git  
  3. ./configure  
  4. bazel build tensorflow/tools/graph_transforms:transform_graph  
  5. bazel build tensorflow/lite/toco:toco   
  6.   
  7. bazel build tensorflow/python/tools:freeze_graph   
  8.   
  9. 使用ssdlite训练生成的模型,使用research/object_detection/export_tflite_ssd_graph.py转换为tflite_graph.pbtflite_graph.pbtxt  
  10. 然后在tensorflow/tensorflow文件夹中使用命令,将其转换为detect.tflite文件。  
  11.   
  12. bazel run tensorflow/lite/toco:toco --  --input_file=/home/shzy/disks/project/fingerdtpaper/models/data/stept_finger/model/ssdlite/tflite_graph.pb --output_file=/home/shzy/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' --inference_type=QUANTIZED_UINT8 --mean_values=128 --std_values=128 --change_concat_input_ranges=false --allow_custom_ops --default_ranges_min=0 --default_ranges_max=255  
  13.   
  14. bazel run tensorflow/lite/toco:toco --  --input_file=/home/shzy/disks/project/fingerdtpaper/models/data/stept_finger/model/ssdlite/tflite_graph.pb --output_file=/home/shzy/detect_float.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' --inference_type=FLOAT --mean_values=128 --std_values=128 --change_concat_input_ranges=false --allow_custom_ops --default_ranges_min=0 --default_ranges_max=255  
  15.   
  16. 如果不转换为tflite文件,可以使用transform_graph转换为  
  17. bazel-bin/tensorflow/tools/graph_transforms/transform_graph --in_graph=/home/shzy/frozen_inference_graph.pb --out_graph=/home/shzy/optimized_frozen_inference_graph.pb  --inputs="image_tensor"  --outputs="detection_boxes,detection_classes,detection_scores" --transforms='fold_old_batch_norms quantize_weights strip_unused_nodes sort_by_execution_order merge_duplicate_nodes'  
  18. 参考的内容是:https://blog.csdn.net/aslily1234/article/details/84840885 https://medium.com/tensorflow/training-and-serving-a-realtime-mobile-object-detector-in-30-minutes-with-cloud-tpus-b78971cf1193  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

九是否随机的称呼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值