diff --git a/README_ch.md b/README_ch.md index 2d543806ce2376188fd32656b75e759d6b611a3b..0c5d4e1c3e8237a0e3a96d6a581f8662e221e37a 100755 --- a/README_ch.md +++ b/README_ch.md @@ -78,7 +78,7 @@ PaddleOCR同时支持动态图与静态图两种编程范式 - 算法介绍 - [文本检测](./doc/doc_ch/algorithm_overview.md) - [文本识别](./doc/doc_ch/algorithm_overview.md) - - [PP-OCR Pipline](#PP-OCR) + - [PP-OCR Pipeline](#PP-OCR) - [端到端PGNet算法](./doc/doc_ch/pgnet.md) - 模型训练/评估 - [文本检测](./doc/doc_ch/detection.md) @@ -113,7 +113,7 @@ PaddleOCR同时支持动态图与静态图两种编程范式 -## PP-OCR Pipline +## PP-OCR Pipeline
diff --git a/deploy/cpp_infer/src/postprocess_op.cpp b/deploy/cpp_infer/src/postprocess_op.cpp index bc794c8189abbec8c3bcb118cb8aca26dcf0c290..e7db70f3bff81390728c6b373b89cf06c74e4eca 100644 --- a/deploy/cpp_infer/src/postprocess_op.cpp +++ b/deploy/cpp_infer/src/postprocess_op.cpp @@ -186,18 +186,23 @@ float PostProcessor::PolygonScoreAcc(std::vector contour, cv::Mat mask; mask = cv::Mat::zeros(ymax - ymin + 1, xmax - xmin + 1, CV_8UC1); - cv::Point rook_point[contour.size()]; + + cv::Point* rook_point = new cv::Point[contour.size()]; + for (int i = 0; i < contour.size(); ++i) { rook_point[i] = cv::Point(int(box_x[i]) - xmin, int(box_y[i]) - ymin); } const cv::Point *ppt[1] = {rook_point}; int npt[] = {int(contour.size())}; + + cv::fillPoly(mask, ppt, npt, 1, cv::Scalar(1)); cv::Mat croppedImg; - pred(cv::Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1)) - .copyTo(croppedImg); + pred(cv::Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1)).copyTo(croppedImg); float score = cv::mean(croppedImg, mask)[0]; + + delete []rook_point; return score; } diff --git a/tools/program.py b/tools/program.py index 33bd35c23d0b6676edfb9c537e497eb68b828c4a..ad6fcbd9b5a1213e7e88ef7c82fde07ff29bcb80 100755 --- a/tools/program.py +++ b/tools/program.py @@ -197,9 +197,11 @@ def train(config, train_reader_cost = 0.0 batch_sum = 0 batch_start = time.time() + max_iter = len(train_dataloader) - 1 if platform.system( + ) == "Windows" else len(train_dataloader) for idx, batch in enumerate(train_dataloader): train_reader_cost += time.time() - batch_start - if idx >= len(train_dataloader): + if idx >= max_iter: break lr = optimizer.get_lr() images = batch[0]