Import and inference INT8 quantized TFLite model#23409
Import and inference INT8 quantized TFLite model#23409asmorkalov merged 10 commits intoopencv:4.xfrom
Conversation
|
Ubuntu 20.04: |
8a10784 to
166890b
Compare
| Mat parseTensor(const Tensor& tensor); | ||
|
|
||
| typedef void (TFLiteImporter::*TFLiteImporterNodeParser)(const Operator&, const std::string&, LayerParams&); | ||
| typedef void (TFLiteImporter::*TFLiteImporterNodeParser)(const Operator&, const std::string&, LayerParams&, LayerParams&); |
There was a problem hiding this comment.
This should not be a common change.
Many handlers just don't use activParams at all.
Compiler warnings are disabled in dnn module, many warnings are really generated here for that change.
| // Connect layer to inputs | ||
| int i = 0; | ||
| for (int idx : layerInputs) { | ||
| std::vector<DataLayout> inpLayouts; |
There was a problem hiding this comment.
Problem of handlers API is here.
We should not have any heavy postprocessing after the handler call.
Post-processing should be done in the handler itself (because handler defines post-processing steps).
Provide a method for registration of DNN layers to be called from handlers.
See ONNX importer implementation for reference.
There was a problem hiding this comment.
Thanks! I reworked both fused activations logic and created an addLayer method. Here is a graph for EfficientDet I used to verify that activations were added correctly: efficientdet.dot (efficientdet.pdf). Unfortunately, for this model they work as identity function and even with unconnected activations, test passes.
opencv-alalek
left a comment
There was a problem hiding this comment.
Well done 👍 Thank you!
|
@opencv-alalek, thanks for the review! |
Import and inference INT8 quantized TFLite model opencv#23409 ### Pull Request Readiness Checklist * Support quantized TFLite models * Enable fused activations (FP32, INT8) **Merge with extra**: opencv/opencv_extra#1048  on the image, green boxes are from TFLite and red boxes from OpenCV See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Import and inference INT8 quantized TFLite model opencv#23409 ### Pull Request Readiness Checklist * Support quantized TFLite models * Enable fused activations (FP32, INT8) **Merge with extra**: opencv/opencv_extra#1048  on the image, green boxes are from TFLite and red boxes from OpenCV See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Pull Request Readiness Checklist
Merge with extra: opencv/opencv_extra#1048
on the image, green boxes are from TFLite and red boxes from OpenCV
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.