[Bug Fix] Fix PPOCR dynamic input shape bug (#667)

* Imporve OCR Readme

* Improve OCR Readme

* Improve OCR Readme

* Improve OCR Readme

* Improve OCR Readme

* Add Initialize function to PP-OCR

* Add Initialize function to PP-OCR

* Add Initialize function to PP-OCR

* Make all the model links come from PaddleOCR

* Improve OCR readme

* Improve OCR readme

* Improve OCR readme

* Improve OCR readme

* Add Readme for vision results

* Add Readme for vision results

* Add Readme for vision results

* Add Readme for vision results

* Add Readme for vision results

* Add Readme for vision results

* Add Readme for vision results

* Add Readme for vision results

* Add Readme for vision results

* Add Readme for vision results

* Add check for label file in postprocess of Rec model

* Add check for label file in postprocess of Rec model

* Add check for label file in postprocess of Rec model

* Add check for label file in postprocess of Rec model

* Add check for label file in postprocess of Rec model

* Add check for label file in postprocess of Rec model

* Add comments to create API docs

* Improve OCR comments

* Rename OCR and add comments

* Make sure previous python example works

* Make sure previous python example works

* Fix Rec model bug

* Fix Rec model bug

* Fix rec model bug

* Add SetTrtMaxBatchSize function for TensorRT

* Add SetTrtMaxBatchSize Pybind

* Add set_trt_max_batch_size python function

* Set TRT dynamic shape in PPOCR examples

* Set TRT dynamic shape in PPOCR examples

* Set TRT dynamic shape in PPOCR examples

* Fix PPOCRv2 python example

* Fix PPOCR dynamic input shape bug

* Remove useless code

Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
yunyaoXYY
2022-11-23 10:14:58 +08:00
committed by GitHub
parent 712d7fd71b
commit 737c7939ff
4 changed files with 69 additions and 39 deletions

View File

@@ -33,12 +33,13 @@ void InitAndInfer(const std::string& det_model_dir, const std::string& cls_model
auto cls_option = option;
auto rec_option = option;
// If use TRT backend, the dynamic shape will be set as follow.
det_option.SetTrtInputShape("x", {1, 3, 50, 50}, {1, 3, 640, 640},
{1, 3, 1536, 1536});
cls_option.SetTrtInputShape("x", {1, 3, 48, 10}, {1, 3, 48, 320}, {1, 3, 48, 1024});
rec_option.SetTrtInputShape("x", {1, 3, 48, 10}, {1, 3, 48, 320},
{1, 3, 48, 2304});
// If use TRT backend, the dynamic shape will be set as follow.
// We recommend that users set the length and height of the detection model to a multiple of 32.
det_option.SetTrtInputShape("x", {1, 3, 64,64}, {1, 3, 640, 640},
{1, 3, 960, 960});
cls_option.SetTrtInputShape("x", {1, 3, 48, 10}, {10, 3, 48, 320}, {64, 3, 48, 1024});
rec_option.SetTrtInputShape("x", {1, 3, 48, 10}, {10, 3, 48, 320},
{64, 3, 48, 2304});
// Users could save TRT cache file to disk as follow.
// det_option.SetTrtCacheFile(det_model_dir + sep + "det_trt_cache.trt");
@@ -103,6 +104,11 @@ int main(int argc, char* argv[]) {
} else if (flag == 2) {
option.UseGpu();
option.UseTrtBackend();
} else if (flag == 3) {
option.UseGpu();
option.UseTrtBackend();
option.EnablePaddleTrtCollectShape();
option.EnablePaddleToTrt();
}
std::string det_model_dir = argv[1];