Open SanjayGhanagiri opened 2 years ago
same question
same question
I can leave a short comment, as I chase this path as well.
You can use pintos openvino to convert to tflite. However you will need to convert to onnx before, which export.py will do for you. But the process is fairly straightfroward.
But it seems to give some OPs that is currently not supported by tflite - std or nightly packages - Pinto addsome magic that is ahead of the tensorflow people.. :-)
An alternate path that I am testing right now is to use onnx-tensorflowpackage.
However, it seems Input in yolov7/pytorch is NCHW and tensorflow/tflite expects NWHC. Im sure there are a lot of way to manage this but what Im going after is to change the graf to manage that input.
But then you also have to manage NMS, in code (faster if native) or graph, some imagemanipulation as the boundingbox in tensorflow lite is normalize 0..1 and then also will need to quantize it to get reasonable speed.
Note2: Im doing it for a flutter app where I have yolov5s fp32 model take 40-50 Ms inference time on iPhone 11 pro, coreml delegated.
@mfagerdal Thanks for the sharing a lot of info. Am exactly on the same path as well. Trying to test tflite, coreML, torchscript models on flutter app.
Dont you think conversion from onnx to tflite would reduce the model accuracy ?
@SanjayGhanagiri
Dont you think conversion from onnx to tflite would reduce the model accuracy ? No. Only quantization to fp16 and int will do that in general. uint8 will reduce accuracy but much faster BUT will not get coreml delegate speedup (only fp32 and fp16) pytorch for mobile looks promising but seems slow still. coreml is great but not in flutter - ie there is no package yet that can manage simultaneous tflite native on android and coreml native on ios.
Does somebody solved the "yolov7/pytorch is NCHW and tensorflow/tflite expects NWHC" problem?
@Construct705 Did you find the solution?
No sorry, i switched back to yolov5
vi-jay-m @.***> schrieb am Fr., 30. Dez. 2022, 06:57:
@Construct705 https://github.com/Construct705 Did you find the solution?
— Reply to this email directly, view it on GitHub https://github.com/WongKinYiu/yolov7/issues/686#issuecomment-1367741288, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3TMSHYEUNFY5JYAOPD2LFLWPZ2TJANCNFSM6AAAAAAQCLYE24 . You are receiving this because you were mentioned.Message ID: @.***>
Did you find the solution? if i converted and run tflite in Android Bounding box get mismatched it not giving correct output
what we found is pytorch and tf exports onnx format differently NCHW and tensorflow/tflite expects NWHC.
Maybe solution is to train yolov7 in tf and export into tflie?
@Jumabek Doesn't TF support both channel first and channel last format?. The same model can be used as it is in TF. The user will just have to swap the channel axes while running inference. I don't know about Android though how can that be done.
python3 export.py --weights runs/train/exp5/weights/last.pt --include tflite --img 416 --data custom-dataset.yaml
We can do this on yolov5 models. Is this possible on yolov7 ?