Skip to content

Commit

Permalink
[Bug Fix] Fix PPOCR bug when cls model is not used (PaddlePaddle#695)
Browse files Browse the repository at this point in the history
* 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

* Fix PPOCR bug

Co-authored-by: Jason <[email protected]>
  • Loading branch information
yunyaoXYY and jiangjiajun authored Nov 25, 2022
1 parent 256f7c2 commit d0fa2fc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions fastdeploy/vision/ocr/ppocr/ppocr_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,19 @@ bool PPOCRv2::BatchPredict(const std::vector<cv::Mat>& images,
std::vector<std::string>* text_ptr = &ocr_result.text;
std::vector<float>* rec_scores_ptr = &ocr_result.rec_scores;

if (!classifier_->BatchPredict(image_list, cls_labels_ptr, cls_scores_ptr)) {
FDERROR << "There's error while recognizing image in PPOCR." << std::endl;
return false;
}else{
for (size_t i_img = 0; i_img < image_list.size(); ++i_img) {
if(cls_labels_ptr->at(i_img) % 2 == 1 && cls_scores_ptr->at(i_img) > classifier_->postprocessor_.cls_thresh_) {
cv::rotate(image_list[i_img], image_list[i_img], 1);
if (nullptr != classifier_){
if (!classifier_->BatchPredict(image_list, cls_labels_ptr, cls_scores_ptr)) {
FDERROR << "There's error while recognizing image in PPOCR." << std::endl;
return false;
}else{
for (size_t i_img = 0; i_img < image_list.size(); ++i_img) {
if(cls_labels_ptr->at(i_img) % 2 == 1 && cls_scores_ptr->at(i_img) > classifier_->postprocessor_.cls_thresh_) {
cv::rotate(image_list[i_img], image_list[i_img], 1);
}
}
}
}

if (!recognizer_->BatchPredict(image_list, text_ptr, rec_scores_ptr)) {
FDERROR << "There's error while recognizing image in PPOCR." << std::endl;
return false;
Expand Down

0 comments on commit d0fa2fc

Please sign in to comment.