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 db8e44df360d8d255406a13ae697f598d7a96a3a..7e54a2f8c2f1db8881aa476a309c8a8c563fcae5 100755 --- a/tools/program.py +++ b/tools/program.py @@ -199,8 +199,12 @@ def train(config, train_reader_cost = 0.0 batch_sum = 0 batch_start = time.time() - for idx, batch in enumerate(train_dataloader()): + 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 >= max_iter: + break lr = optimizer.get_lr() images = batch[0] if use_srn: