mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2025-06-03 21:53:39 +08:00
support dynamic trt
This commit is contained in:
parent
50e3bacd32
commit
31a84a33d8
@ -112,6 +112,8 @@ void Classifier::LoadModel(const std::string &model_dir) {
|
||||
precision = paddle_infer::Config::Precision::kInt8;
|
||||
}
|
||||
config.EnableTensorRtEngine(1 << 20, 10, 3, precision, false, false);
|
||||
config.CollectShapeRangeInfo("./trt_shape.txt");
|
||||
config.EnableTunedTensorRtDynamicShape("./trt_shape.txt", true);
|
||||
}
|
||||
} else {
|
||||
config.DisableGpu();
|
||||
|
@ -32,49 +32,10 @@ void DBDetector::LoadModel(const std::string &model_dir) {
|
||||
if (this->precision_ == "int8") {
|
||||
precision = paddle_infer::Config::Precision::kInt8;
|
||||
}
|
||||
config.EnableTensorRtEngine(1 << 20, 1, 20, precision, false, false);
|
||||
std::map<std::string, std::vector<int>> min_input_shape = {
|
||||
{"x", {1, 3, 50, 50}},
|
||||
{"conv2d_92.tmp_0", {1, 120, 20, 20}},
|
||||
{"conv2d_91.tmp_0", {1, 24, 10, 10}},
|
||||
{"conv2d_59.tmp_0", {1, 96, 20, 20}},
|
||||
{"nearest_interp_v2_1.tmp_0", {1, 256, 10, 10}},
|
||||
{"nearest_interp_v2_2.tmp_0", {1, 256, 20, 20}},
|
||||
{"conv2d_124.tmp_0", {1, 256, 20, 20}},
|
||||
{"nearest_interp_v2_3.tmp_0", {1, 64, 20, 20}},
|
||||
{"nearest_interp_v2_4.tmp_0", {1, 64, 20, 20}},
|
||||
{"nearest_interp_v2_5.tmp_0", {1, 64, 20, 20}},
|
||||
{"elementwise_add_7", {1, 56, 2, 2}},
|
||||
{"nearest_interp_v2_0.tmp_0", {1, 256, 2, 2}}};
|
||||
std::map<std::string, std::vector<int>> max_input_shape = {
|
||||
{"x", {1, 3, 1536, 1536}},
|
||||
{"conv2d_92.tmp_0", {1, 120, 400, 400}},
|
||||
{"conv2d_91.tmp_0", {1, 24, 200, 200}},
|
||||
{"conv2d_59.tmp_0", {1, 96, 400, 400}},
|
||||
{"nearest_interp_v2_1.tmp_0", {1, 256, 200, 200}},
|
||||
{"nearest_interp_v2_2.tmp_0", {1, 256, 400, 400}},
|
||||
{"conv2d_124.tmp_0", {1, 256, 400, 400}},
|
||||
{"nearest_interp_v2_3.tmp_0", {1, 64, 400, 400}},
|
||||
{"nearest_interp_v2_4.tmp_0", {1, 64, 400, 400}},
|
||||
{"nearest_interp_v2_5.tmp_0", {1, 64, 400, 400}},
|
||||
{"elementwise_add_7", {1, 56, 400, 400}},
|
||||
{"nearest_interp_v2_0.tmp_0", {1, 256, 400, 400}}};
|
||||
std::map<std::string, std::vector<int>> opt_input_shape = {
|
||||
{"x", {1, 3, 640, 640}},
|
||||
{"conv2d_92.tmp_0", {1, 120, 160, 160}},
|
||||
{"conv2d_91.tmp_0", {1, 24, 80, 80}},
|
||||
{"conv2d_59.tmp_0", {1, 96, 160, 160}},
|
||||
{"nearest_interp_v2_1.tmp_0", {1, 256, 80, 80}},
|
||||
{"nearest_interp_v2_2.tmp_0", {1, 256, 160, 160}},
|
||||
{"conv2d_124.tmp_0", {1, 256, 160, 160}},
|
||||
{"nearest_interp_v2_3.tmp_0", {1, 64, 160, 160}},
|
||||
{"nearest_interp_v2_4.tmp_0", {1, 64, 160, 160}},
|
||||
{"nearest_interp_v2_5.tmp_0", {1, 64, 160, 160}},
|
||||
{"elementwise_add_7", {1, 56, 40, 40}},
|
||||
{"nearest_interp_v2_0.tmp_0", {1, 256, 40, 40}}};
|
||||
|
||||
config.SetTRTDynamicShapeInfo(min_input_shape, max_input_shape,
|
||||
opt_input_shape);
|
||||
config.EnableTensorRtEngine(1 << 30, 1, 20, precision, false, false);
|
||||
config.CollectShapeRangeInfo("./trt_shape.txt");
|
||||
config.EnableTunedTensorRtDynamicShape("./trt_shape.txt", true);
|
||||
|
||||
}
|
||||
} else {
|
||||
config.DisableGpu();
|
||||
|
@ -148,19 +148,9 @@ void CRNNRecognizer::LoadModel(const std::string &model_dir) {
|
||||
precision = paddle_infer::Config::Precision::kInt8;
|
||||
}
|
||||
config.EnableTensorRtEngine(1 << 20, 10, 15, precision, false, false);
|
||||
int imgH = this->rec_image_shape_[1];
|
||||
int imgW = this->rec_image_shape_[2];
|
||||
std::map<std::string, std::vector<int>> min_input_shape = {
|
||||
{"x", {1, 3, imgH, 10}}, {"lstm_0.tmp_0", {10, 1, 96}}};
|
||||
std::map<std::string, std::vector<int>> max_input_shape = {
|
||||
{"x", {this->rec_batch_num_, 3, imgH, 2500}},
|
||||
{"lstm_0.tmp_0", {1000, 1, 96}}};
|
||||
std::map<std::string, std::vector<int>> opt_input_shape = {
|
||||
{"x", {this->rec_batch_num_, 3, imgH, imgW}},
|
||||
{"lstm_0.tmp_0", {25, 1, 96}}};
|
||||
|
||||
config.SetTRTDynamicShapeInfo(min_input_shape, max_input_shape,
|
||||
opt_input_shape);
|
||||
config.CollectShapeRangeInfo("./trt_shape.txt");
|
||||
config.EnableTunedTensorRtDynamicShape("./trt_shape.txt", true);
|
||||
|
||||
}
|
||||
} else {
|
||||
config.DisableGpu();
|
||||
|
Loading…
x
Reference in New Issue
Block a user