Closed Alter-Y closed 1 year ago
int8的tflite模型,需要对输入输出做量化和反量化处理,也许你是这一步没做对。 这个是依据onnx的模型结构来导出的,yolov5官方的tflite是通过代码来构建的。
int8的tflite模型,需要对输入输出做量化和反量化处理,也许你是这一步没做对。 这个是依据onnx的模型结构来导出的,yolov5官方的tflite是通过代码来构建的。
你好,我是直接用yolov5的源码进行测试的,肯定有量化跟反量化处理,用的coco128标准数据集。作者是怎么验证yolo模型的呢?
YOLOV5的源码我看了,他没有写量化的这一部分代码。你可以先试试不量化的能不能推对,我以前是专门测试过的,但是代码找不到了,不过INT8的tflite模型在PC上推理非常慢 你可以参照这个写一下: https://www.tensorflow.org/lite/performance/post_training_quantization https://stackoverflow.com/questions/66767195/run-inference-with-quantized-tflite-model-int8-in-python
好的,谢谢,我先尝试一下。
殇痕*秋雪 @.***
------------------ 原始邮件 ------------------ 发件人: "MPolaris/onnx2tflite" @.>; 发送时间: 2022年12月5日(星期一) 中午11:21 @.>; @.**@.>; 主题: Re: [MPolaris/onnx2tflite] yolov5s.onnx转换keras,tflite的验证测试 (Issue #24)
YOLOV5的源码我看了,他没有写量化的这一部分代码。你可以先试试不量化的能不能推对,我以前是专门测试过的,但是代码找不到了,不过INT8的tflite模型在PC上推理非常慢 你可以参照这个写一下: https://www.tensorflow.org/lite/performance/post_training_quantization https://stackoverflow.com/questions/66767195/run-inference-with-quantized-tflite-model-int8-in-python
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
我使用yolov5的转换方式将yolov5s.pt转换成onnx,再通过onnx2tflite的转换命令转换成keras和tflite。 PS E:\pycharm_proj\yolov5_switf_test\onnx2tflite> python .\converter.py --weights ./yolov5s.onnx --formats tflite keras --int8 --imgroot .\datasets\coco128\images\train2017\ --int8mean 0 0 0 --int8std 255 255 255 Checking 0/1... [0] redundant input nodes are removed. nodes name : E:\yolov5-master\venv\lib\site-packages\tensorflow\lite\python\convert.py:746: UserWarning: Statistics for quantized inputs were expected, but not specified; cont inuing anyway. warnings.warn("Statistics for quantized inputs were expected, but not " Estimated count of arithmetic ops: 18.144 G ops, equivalently 9.072 G MACs fully_quantize: 0, inference_type: 6, input_inference_type: 3, output_inference_type: 3 Estimated count of arithmetic ops: 18.144 G ops, equivalently 9.072 G MACs WARNING:tensorflow:Compiled the loaded model, but the compiled metrics have yet to be built.
model.compile_metrics
will be empty until you train or evaluate the model. WARNING:tensorflow:Compiled the loaded model, but the compiled metrics have yet to be built.model.compile_metrics
will be empty until you train or evaluate the model. 但首先我使用netron打不开h5,其次我使用yolov5的验证命令对tflite进行测试,先是shape的问题会报错,onnx2tflite输出的shape是[1, 85, 25200],而yolov5中输出是[1. 25200, 85],所以我修改了yolov5 val.py,line206out = out.permute(0, 2, 1) # onnx2tflite: [1, 85, 25200] to [1, 25200, 85]
,再测试得到的输出显示为0是:请问,我的测试流程是否有问题?作者是用什么方式进行验证测试yolov5的?另外这里得到的tflite与yolov5导出的tflite相比,会多出许多transpose和gather操作,这是什么问题导致的? 附:onnx2tflite导出的tflite: yolov5s_onnx2tflite.zip yolov5的tflite: yolov5s-int8.zip