Skip to content

Commit

Permalink
Merge pull request #3696 from MissPenguin/dygraph
Browse files Browse the repository at this point in the history
add benchmark log
  • Loading branch information
MissPenguin authored Aug 17, 2021
2 parents 74e0d11 + 25de5be commit a81b88a
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 245 deletions.
6 changes: 3 additions & 3 deletions deploy/cpp_infer/include/ocr_cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Classifier {
const int &gpu_id, const int &gpu_mem,
const int &cpu_math_library_num_threads,
const bool &use_mkldnn, const double &cls_thresh,
const bool &use_tensorrt, const bool &use_fp16) {
const bool &use_tensorrt, const std::string &precision) {
this->use_gpu_ = use_gpu;
this->gpu_id_ = gpu_id;
this->gpu_mem_ = gpu_mem;
Expand All @@ -51,7 +51,7 @@ class Classifier {

this->cls_thresh = cls_thresh;
this->use_tensorrt_ = use_tensorrt;
this->use_fp16_ = use_fp16;
this->precision_ = precision;

LoadModel(model_dir);
}
Expand All @@ -75,7 +75,7 @@ class Classifier {
std::vector<float> scale_ = {1 / 0.5f, 1 / 0.5f, 1 / 0.5f};
bool is_scale_ = true;
bool use_tensorrt_ = false;
bool use_fp16_ = false;
std::string precision_ = "fp32";
// pre-process
ClsResizeImg resize_op_;
Normalize normalize_op_;
Expand Down
8 changes: 4 additions & 4 deletions deploy/cpp_infer/include/ocr_det.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DBDetector {
const double &det_db_box_thresh,
const double &det_db_unclip_ratio,
const bool &use_polygon_score, const bool &visualize,
const bool &use_tensorrt, const bool &use_fp16) {
const bool &use_tensorrt, const std::string &precision) {
this->use_gpu_ = use_gpu;
this->gpu_id_ = gpu_id;
this->gpu_mem_ = gpu_mem;
Expand All @@ -62,7 +62,7 @@ class DBDetector {

this->visualize_ = visualize;
this->use_tensorrt_ = use_tensorrt;
this->use_fp16_ = use_fp16;
this->precision_ = precision;

LoadModel(model_dir);
}
Expand All @@ -71,7 +71,7 @@ class DBDetector {
void LoadModel(const std::string &model_dir);

// Run predictor
void Run(cv::Mat &img, std::vector<std::vector<std::vector<int>>> &boxes);
void Run(cv::Mat &img, std::vector<std::vector<std::vector<int>>> &boxes, std::vector<double> *times);

private:
std::shared_ptr<Predictor> predictor_;
Expand All @@ -91,7 +91,7 @@ class DBDetector {

bool visualize_ = true;
bool use_tensorrt_ = false;
bool use_fp16_ = false;
std::string precision_ = "fp32";

std::vector<float> mean_ = {0.485f, 0.456f, 0.406f};
std::vector<float> scale_ = {1 / 0.229f, 1 / 0.224f, 1 / 0.225f};
Expand Down
11 changes: 4 additions & 7 deletions deploy/cpp_infer/include/ocr_rec.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ class CRNNRecognizer {
const int &gpu_id, const int &gpu_mem,
const int &cpu_math_library_num_threads,
const bool &use_mkldnn, const string &label_path,
const bool &use_tensorrt, const bool &use_fp16) {
const bool &use_tensorrt, const std::string &precision) {
this->use_gpu_ = use_gpu;
this->gpu_id_ = gpu_id;
this->gpu_mem_ = gpu_mem;
this->cpu_math_library_num_threads_ = cpu_math_library_num_threads;
this->use_mkldnn_ = use_mkldnn;
this->use_tensorrt_ = use_tensorrt;
this->use_fp16_ = use_fp16;
this->precision_ = precision;

this->label_list_ = Utility::ReadDict(label_path);
this->label_list_.insert(this->label_list_.begin(),
Expand All @@ -64,7 +64,7 @@ class CRNNRecognizer {
// Load Paddle inference model
void LoadModel(const std::string &model_dir);

void Run(cv::Mat &img);
void Run(cv::Mat &img, std::vector<double> *times);

private:
std::shared_ptr<Predictor> predictor_;
Expand All @@ -81,7 +81,7 @@ class CRNNRecognizer {
std::vector<float> scale_ = {1 / 0.5f, 1 / 0.5f, 1 / 0.5f};
bool is_scale_ = true;
bool use_tensorrt_ = false;
bool use_fp16_ = false;
std::string precision_ = "fp32";
// pre-process
CrnnResizeImg resize_op_;
Normalize normalize_op_;
Expand All @@ -90,9 +90,6 @@ class CRNNRecognizer {
// post-process
PostProcessor post_processor_;

cv::Mat GetRotateCropImage(const cv::Mat &srcimage,
std::vector<std::vector<int>> box);

}; // class CrnnRecognizer

} // namespace PaddleOCR
3 changes: 3 additions & 0 deletions deploy/cpp_infer/include/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class Utility {

static void GetAllFiles(const char *dir_name,
std::vector<std::string> &all_inputs);

static cv::Mat GetRotateCropImage(const cv::Mat &srcimage,
std::vector<std::vector<int>> box);
};

} // namespace PaddleOCR
Loading

0 comments on commit a81b88a

Please sign in to comment.