|
@@ -23,7 +23,7 @@ void Model::create_predictor(const std::string& model_dir,
|
|
|
bool use_trt,
|
|
bool use_trt,
|
|
|
int gpu_id,
|
|
int gpu_id,
|
|
|
std::string key,
|
|
std::string key,
|
|
|
- int batch_size) {
|
|
|
|
|
|
|
+ bool use_ir_optim) {
|
|
|
paddle::AnalysisConfig config;
|
|
paddle::AnalysisConfig config;
|
|
|
std::string model_file = model_dir + OS_PATH_SEP + "__model__";
|
|
std::string model_file = model_dir + OS_PATH_SEP + "__model__";
|
|
|
std::string params_file = model_dir + OS_PATH_SEP + "__params__";
|
|
std::string params_file = model_dir + OS_PATH_SEP + "__params__";
|
|
@@ -64,6 +64,8 @@ void Model::create_predictor(const std::string& model_dir,
|
|
|
}
|
|
}
|
|
|
config.SwitchUseFeedFetchOps(false);
|
|
config.SwitchUseFeedFetchOps(false);
|
|
|
config.SwitchSpecifyInputNames(true);
|
|
config.SwitchSpecifyInputNames(true);
|
|
|
|
|
+ // 开启图优化
|
|
|
|
|
+ config.SwitchIrOptim(use_ir_optim);
|
|
|
// 开启内存优化
|
|
// 开启内存优化
|
|
|
config.EnableMemoryOptim();
|
|
config.EnableMemoryOptim();
|
|
|
if (use_trt) {
|
|
if (use_trt) {
|
|
@@ -76,7 +78,6 @@ void Model::create_predictor(const std::string& model_dir,
|
|
|
false /* use_calib_mode*/);
|
|
false /* use_calib_mode*/);
|
|
|
}
|
|
}
|
|
|
predictor_ = std::move(CreatePaddlePredictor(config));
|
|
predictor_ = std::move(CreatePaddlePredictor(config));
|
|
|
- inputs_batch_.assign(batch_size, ImageBlob());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool Model::load_config(const std::string& yaml_input) {
|
|
bool Model::load_config(const std::string& yaml_input) {
|
|
@@ -192,6 +193,7 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
|
|
|
"to function predict()!" << std::endl;
|
|
"to function predict()!" << std::endl;
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+ inputs_batch_.assign(im_batch.size(), ImageBlob());
|
|
|
// 处理输入图像
|
|
// 处理输入图像
|
|
|
if (!preprocess(im_batch, &inputs_batch_, thread_num)) {
|
|
if (!preprocess(im_batch, &inputs_batch_, thread_num)) {
|
|
|
std::cerr << "Preprocess failed!" << std::endl;
|
|
std::cerr << "Preprocess failed!" << std::endl;
|
|
@@ -356,6 +358,7 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ inputs_batch_.assign(im_batch.size(), ImageBlob());
|
|
|
int batch_size = im_batch.size();
|
|
int batch_size = im_batch.size();
|
|
|
// 处理输入图像
|
|
// 处理输入图像
|
|
|
if (!preprocess(im_batch, &inputs_batch_, thread_num)) {
|
|
if (!preprocess(im_batch, &inputs_batch_, thread_num)) {
|
|
@@ -637,6 +640,7 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 处理输入图像
|
|
// 处理输入图像
|
|
|
|
|
+ inputs_batch_.assign(im_batch.size(), ImageBlob());
|
|
|
if (!preprocess(im_batch, &inputs_batch_, thread_num)) {
|
|
if (!preprocess(im_batch, &inputs_batch_, thread_num)) {
|
|
|
std::cerr << "Preprocess failed!" << std::endl;
|
|
std::cerr << "Preprocess failed!" << std::endl;
|
|
|
return false;
|
|
return false;
|