From 946c3a08df7d22e134bc55536a70de3dd3c0483e Mon Sep 17 00:00:00 2001 From: whjdark Date: Wed, 13 Jul 2022 19:54:27 +0800 Subject: [PATCH 01/10] new new commit --- PPOCRLabel/PPOCRLabel.py | 1 - PPOCRLabel/libs/shape.py | 1 - 2 files changed, 2 deletions(-) diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 8538e8ed3f..440c2d8c3e 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -21,7 +21,6 @@ import os.path import platform import subprocess import sys -from tkinter.tix import Tree import xlrd from functools import partial diff --git a/PPOCRLabel/libs/shape.py b/PPOCRLabel/libs/shape.py index af12a5eb53..180456a10c 100644 --- a/PPOCRLabel/libs/shape.py +++ b/PPOCRLabel/libs/shape.py @@ -12,7 +12,6 @@ # THE SOFTWARE. # !/usr/bin/python # -*- coding: utf-8 -*- -from email.policy import default import math import sys From 8a98fb0c86ffa70fe135c4a2aa511b66eb320b3d Mon Sep 17 00:00:00 2001 From: whjdark Date: Wed, 20 Jul 2022 18:44:57 +0800 Subject: [PATCH 02/10] new commit --- PPOCRLabel/libs/shape.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PPOCRLabel/libs/shape.py b/PPOCRLabel/libs/shape.py index 180456a10c..1b32a6af14 100644 --- a/PPOCRLabel/libs/shape.py +++ b/PPOCRLabel/libs/shape.py @@ -125,7 +125,8 @@ class Shape(object): color = self.select_line_color if self.selected else self.line_color pen = QPen(color) # Try using integer sizes for smoother drawing(?) - pen.setWidth(max(1, int(round(2.0 / self.scale)))) + # no need, it casuses that font is too small in high-resolusion image + # pen.setWidth(max(1, int(round(2.0 / self.scale)))) painter.setPen(pen) line_path = QPainterPath() From 50af18d44cf87055b5732db55afed63d51c243b2 Mon Sep 17 00:00:00 2001 From: Topdu <784990967@qq.com> Date: Thu, 21 Jul 2022 02:53:51 +0000 Subject: [PATCH 03/10] fix vitstr yml bug --- configs/rec/rec_vitstr_none_ce.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/rec/rec_vitstr_none_ce.yml b/configs/rec/rec_vitstr_none_ce.yml index 13a7d7d1bc..ebe304fa4b 100644 --- a/configs/rec/rec_vitstr_none_ce.yml +++ b/configs/rec/rec_vitstr_none_ce.yml @@ -81,7 +81,7 @@ Train: Eval: dataset: name: LMDBDataSet - data_dir: ./train_data/data_lmdb_release/evaluaiton/ + data_dir: ./train_data/data_lmdb_release/evaluation/ transforms: - DecodeImage: # load image img_mode: BGR From ce600ab56f9e72f58b3fcb578d315b9db20ff402 Mon Sep 17 00:00:00 2001 From: Topdu <784990967@qq.com> Date: Thu, 21 Jul 2022 04:50:31 +0000 Subject: [PATCH 04/10] add abinet pretrained model --- configs/rec/rec_r45_abinet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/rec/rec_r45_abinet.yml b/configs/rec/rec_r45_abinet.yml index 3c5e51229f..bc9048a200 100644 --- a/configs/rec/rec_r45_abinet.yml +++ b/configs/rec/rec_r45_abinet.yml @@ -8,7 +8,7 @@ Global: # evaluation is run every 2000 iterations eval_batch_step: [0, 2000] cal_metric_during_train: True - pretrained_model: + pretrained_model: ./pretrain_models/abinet_vl_pretrained checkpoints: save_inference_dir: use_visualdl: False From 81f29c936f2e1d03b6d7344ab366c73238cac5f4 Mon Sep 17 00:00:00 2001 From: whjdark Date: Thu, 21 Jul 2022 15:28:03 +0800 Subject: [PATCH 05/10] new commit --- PPOCRLabel/libs/canvas.py | 7 +++++++ PPOCRLabel/libs/shape.py | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PPOCRLabel/libs/canvas.py b/PPOCRLabel/libs/canvas.py index 780ca71af5..81f3799512 100644 --- a/PPOCRLabel/libs/canvas.py +++ b/PPOCRLabel/libs/canvas.py @@ -624,6 +624,13 @@ class Canvas(QWidget): pal.setColor(self.backgroundRole(), QColor(232, 232, 232, 255)) self.setPalette(pal) + # adaptive BBOX label & index font size + if self.pixmap: + h, w = self.pixmap.size().height(), self.pixmap.size().width() + fontszie = int(max(h, w) / 48) + for s in self.shapes: + s.fontsize = fontszie + p.end() def fillDrawing(self): diff --git a/PPOCRLabel/libs/shape.py b/PPOCRLabel/libs/shape.py index 1b32a6af14..4e0b1f08c6 100644 --- a/PPOCRLabel/libs/shape.py +++ b/PPOCRLabel/libs/shape.py @@ -66,6 +66,7 @@ class Shape(object): self.NEAR_VERTEX: (4, self.P_ROUND), self.MOVE_VERTEX: (1.5, self.P_SQUARE), } + self.fontsize = 8 self._closed = False @@ -157,7 +158,7 @@ class Shape(object): min_y = min(min_y, point.y()) if min_x != sys.maxsize and min_y != sys.maxsize: font = QFont() - font.setPointSize(8) + font.setPointSize(self.fontsize) font.setBold(True) painter.setFont(font) if self.label is None: @@ -175,7 +176,7 @@ class Shape(object): min_y = min(min_y, point.y()) if min_x != sys.maxsize and min_y != sys.maxsize: font = QFont() - font.setPointSize(8) + font.setPointSize(self.fontsize) font.setBold(True) painter.setFont(font) text = '' From 00fa71d88bd21e059c9437eb96069ad03bbec7c6 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Mon, 25 Jul 2022 20:33:17 +0800 Subject: [PATCH 06/10] set benchmark_train dynamic shape --- test_tipc/benchmark_train.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test_tipc/benchmark_train.sh b/test_tipc/benchmark_train.sh index c74054ed55..19c288ff95 100644 --- a/test_tipc/benchmark_train.sh +++ b/test_tipc/benchmark_train.sh @@ -21,6 +21,20 @@ function func_parser_params(){ echo ${tmp} } +function set_dynamic_epoch(){ + string=$1 + num=$2 + _str=${string:1:6} + IFS="C" + arr=(${_str}) + M=${arr[0]} + P=${arr[1]} + gn=`expr $P - 1` + gpu_num=`expr $gn / $M` + ep=`expr $num \* $M \* $P` + echo $ep +} + function func_sed_params(){ filename=$1 line=$2 @@ -142,7 +156,7 @@ else if [ ${precision} = "fp16" ];then precision="amp" fi - + epoch=$(set_dynamic_epoch $device_num $epoch) fp_items_list=($precision) batch_size_list=($batch_size) device_num_list=($device_num) From 637c62e49f279a9109d1c319a4b6a39c62c90a3d Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Mon, 25 Jul 2022 20:33:52 +0800 Subject: [PATCH 07/10] set benchmark_train dynamic epoch --- test_tipc/benchmark_train.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test_tipc/benchmark_train.sh b/test_tipc/benchmark_train.sh index 19c288ff95..ca85b90905 100644 --- a/test_tipc/benchmark_train.sh +++ b/test_tipc/benchmark_train.sh @@ -156,6 +156,7 @@ else if [ ${precision} = "fp16" ];then precision="amp" fi + epoch=$(set_dynamic_epoch $device_num $epoch) fp_items_list=($precision) batch_size_list=($batch_size) From 99b7da9719a4e843750d37ce5eae3b40ac7a6971 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Mon, 25 Jul 2022 20:39:08 +0800 Subject: [PATCH 08/10] set benchmark_train dynamic epoch --- test_tipc/benchmark_train.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/test_tipc/benchmark_train.sh b/test_tipc/benchmark_train.sh index ca85b90905..1dcb0129e7 100644 --- a/test_tipc/benchmark_train.sh +++ b/test_tipc/benchmark_train.sh @@ -29,8 +29,6 @@ function set_dynamic_epoch(){ arr=(${_str}) M=${arr[0]} P=${arr[1]} - gn=`expr $P - 1` - gpu_num=`expr $gn / $M` ep=`expr $num \* $M \* $P` echo $ep } From e753481471b2223f3b7c0feb4b5437088e2f7635 Mon Sep 17 00:00:00 2001 From: zhoujun Date: Tue, 26 Jul 2022 13:35:26 +0800 Subject: [PATCH 09/10] filter ocr result by table box (#6996) --- ppstructure/table/predict_table.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ppstructure/table/predict_table.py b/ppstructure/table/predict_table.py index aa05459589..becc6daef0 100644 --- a/ppstructure/table/predict_table.py +++ b/ppstructure/table/predict_table.py @@ -129,11 +129,25 @@ class TableSystem(object): def rebuild_table(self, structure_res, dt_boxes, rec_res): pred_structures, pred_bboxes = structure_res + dt_boxes, rec_res = self.filter_ocr_result(pred_bboxes,dt_boxes, rec_res) matched_index = self.match_result(dt_boxes, pred_bboxes) pred_html, pred = self.get_pred_html(pred_structures, matched_index, rec_res) return pred_html, pred + def filter_ocr_result(self, pred_bboxes,dt_boxes, rec_res): + y1 = pred_bboxes[:,1::2].min() + new_dt_boxes = [] + new_rec_res = [] + + for box,rec in zip(dt_boxes, rec_res): + if np.max(box[1::2]) < y1: + continue + new_dt_boxes.append(box) + new_rec_res.append(rec) + return new_dt_boxes, new_rec_res + + def match_result(self, dt_boxes, pred_bboxes): matched = {} for i, gt_box in enumerate(dt_boxes): From d03b25b0e5a821407f5fb2d3cb52a297affa7c08 Mon Sep 17 00:00:00 2001 From: Evezerest <50011306+Evezerest@users.noreply.github.com> Date: Tue, 26 Jul 2022 15:30:38 +0800 Subject: [PATCH 10/10] Update shape.py --- PPOCRLabel/libs/shape.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PPOCRLabel/libs/shape.py b/PPOCRLabel/libs/shape.py index 4e0b1f08c6..121e43b8ae 100644 --- a/PPOCRLabel/libs/shape.py +++ b/PPOCRLabel/libs/shape.py @@ -126,8 +126,7 @@ class Shape(object): color = self.select_line_color if self.selected else self.line_color pen = QPen(color) # Try using integer sizes for smoother drawing(?) - # no need, it casuses that font is too small in high-resolusion image - # pen.setWidth(max(1, int(round(2.0 / self.scale)))) + pen.setWidth(max(1, int(round(2.0 / self.scale)))) painter.setPen(pen) line_path = QPainterPath()