Skip to content

Fix problems of psenet-ctw1500 training and others #664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ You may adapt it to your task/dataset, for example, by running

```shell
# train text detection model DBNet++ on icdar15 dataset
python tools/train.py --config configs/det/dbnet/db++_r50_icdar15.yaml
python tools/train.py --config configs/det/dbnet/dbpp_r50_icdar15.yaml
```

```shell
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ MindOCR在`configs`文件夹中提供系列SoTA的OCR模型及其训练策略,

```shell
# train text detection model DBNet++ on icdar15 dataset
python tools/train.py --config configs/det/dbnet/db++_r50_icdar15.yaml
python tools/train.py --config configs/det/dbnet/dbpp_r50_icdar15.yaml
```
```shell
# train text recognition model CRNN on icdar15 dataset
Expand Down
4 changes: 2 additions & 2 deletions configs/det/dbnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ DBNet and DBNet++ were trained on the ICDAR2015, MSRA-TD500, SCUT-CTW1500, Total
| DBNet | D910x1-MS2.0-G | ResNet-50 | ImageNet | 83.53% | 86.62% | 85.05% | 13.3 s/epoch | 75.2 img/s | [yaml](db_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50-c3a4aa24.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50-c3a4aa24-fbf95c82.mindir) |
| DBNet | D910x8-MS2.2-G | ResNet-50 | ImageNet | 82.62% | 88.54% | 85.48% | 2.3 s/epoch | 435 img/s | [yaml](db_r50_icdar15_8p.yaml) | Coming soon |
| | | | | | | | | | | |
| DBNet++ | D910x1-MS2.0-G | ResNet-50 | SynthText | 85.70% | 87.81% | 86.74% | 17.7 s/epoch | 56 img/s | [yaml](db++_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2-9934aff0.mindir) |
| DBNet++ | D910x1-MS2.2-G | ResNet-50 | SynthText | 86.81% | 86.85% | 86.86% | 12.7 s/epoch | 78.2 img/s | [yaml](db++_r50_icdar15_910.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_910-35dc71f2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_910-35dc71f2-e61a9c37.mindir) |
| DBNet++ | D910x1-MS2.0-G | ResNet-50 | SynthText | 85.70% | 87.81% | 86.74% | 17.7 s/epoch | 56 img/s | [yaml](dbpp_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2-9934aff0.mindir) |
| DBNet++ | D910x1-MS2.2-G | ResNet-50 | SynthText | 86.81% | 86.85% | 86.86% | 12.7 s/epoch | 78.2 img/s | [yaml](dbpp_r50_icdar15_910.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_910-35dc71f2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_910-35dc71f2-e61a9c37.mindir) |
</div>

> The input_shape for exported DBNet MindIR and DBNet++ MindIR in the links are `(1,3,736,1280)` and `(1,3,1152,2048)`, respectively.
Expand Down
6 changes: 3 additions & 3 deletions configs/det/dbnet/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ DBNet和DBNet++在ICDAR2015,MSRA-TD500,SCUT-CTW1500,Total-Text和MLT2017
| DBNet | D910x1-MS2.0-G | ResNet-50 | ImageNet | 83.53% | 86.62% | 85.05% | 13.3 s/epoch | 75.2 img/s | [yaml](db_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50-c3a4aa24.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50-c3a4aa24-fbf95c82.mindir) |
| DBNet | D910x8-MS2.2-G | ResNet-50 | ImageNet | 82.62% | 88.54% | 85.48% | 2.3 s/epoch | 435 img/s | [yaml](db_r50_icdar15_8p.yaml) | Coming soon |
| | | | | | | | | | | |
| DBNet++ | D910x1-MS2.0-G | ResNet-50 | SynthText | 85.70% | 87.81% | 86.74% | 17.7 s/epoch | 56 img/s | [yaml](db++_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2-9934aff0.mindir) |
| DBNet++ | D910x8-MS2.2-G | ResNet-50 | SynthText | 85.41% | 89.55% | 87.43% | 1.78 s/epoch | 432 img/s | [yaml](db++_r50_icdar15_8p.yaml) | Coming soon |
| DBNet++ | D910*x1-MS2.2-G | ResNet-50 | SynthText | 86.81% | 86.85% | 86.86% | 12.7 s/epoch | 78.2 img/s | [yaml](db++_r50_icdar15_910.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_910-35dc71f2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_910-35dc71f2-e61a9c37.mindir) |
| DBNet++ | D910x1-MS2.0-G | ResNet-50 | SynthText | 85.70% | 87.81% | 86.74% | 17.7 s/epoch | 56 img/s | [yaml](dbpp_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2-9934aff0.mindir) |
| DBNet++ | D910x8-MS2.2-G | ResNet-50 | SynthText | 85.41% | 89.55% | 87.43% | 1.78 s/epoch | 432 img/s | [yaml](dbpp_r50_icdar15_8p.yaml) | Coming soon |
| DBNet++ | D910*x1-MS2.2-G | ResNet-50 | SynthText | 86.81% | 86.85% | 86.86% | 12.7 s/epoch | 78.2 img/s | [yaml](dbpp_r50_icdar15_910.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_910-35dc71f2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_910-35dc71f2-e61a9c37.mindir) |
</div>

> 链接中模型DBNet的MindIR导出时的输入Shape为`(1,3,736,1280)`,模型DBNet++的MindIR导出时的输入Shape为`(1,3,1152,2048)`。
Expand Down
9 changes: 6 additions & 3 deletions configs/det/psenet/pse_r152_ctw1500.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ train:
- RandomColorAdjust:
brightness: 0.1255 # 32.0 / 255
saturation: 0.5
- IaaAugment:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mindocr\data\transforms\transforms_factory.py中的IaaAugment调用是否也需要同步修改替换?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改,并同步到0.3.1

Fliplr: { p: 0.5 }
Affine: { rotate: [ -10, 10 ] }
- RandomHorizontalFlip:
p: 0.5
- RandomRotate:
degrees: [ -10, 10 ]
expand_canvas: False
p: 1.0
- PSEGtDecode:
kernel_num: 7
min_shrink_ratio: 0.4
Expand Down
2 changes: 1 addition & 1 deletion deploy/py_infer/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def main():
args = infer_args.get_args()
parallel_pipeline = ParallelPipeline(args)
parallel_pipeline.start_pipeline()
parallel_pipeline.infer_for_images(args.input_images_dir)
parallel_pipeline.infer_for_images(args.input_images_dir, task_id=0)
parallel_pipeline.stop_pipeline()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ def __call__(
src_w, src_h = shape_list[0, 1], shape_list[0, 0]
polys = self.filter_tag_det_res(result["polys"][0], [src_h, src_w])
if self._if_merge_longedge_bbox:
polys = longedge_bbox_merge(polys, self._merge_inter_area_thres, self._merge_ratio, self._merge_angle_theta)
try:
polys = longedge_bbox_merge(
polys, self._merge_inter_area_thres, self._merge_ratio, self._merge_angle_theta
)
except Exception as e:
_logger.warning(f"long edge bbox merge failed: {e}")
if self._if_sort_bbox:
polys = sorted_boxes(polys, self._sort_bbox_y_delta)
result["polys"][0] = polys
Expand Down
6 changes: 3 additions & 3 deletions deploy/py_infer/src/parallel/parallel_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def start_pipeline(self):
def stop_pipeline(self):
self.pipeline_manager.stop_pipeline()

def infer_for_images(self, input_images_dir, task_id):
def infer_for_images(self, input_images_dir, task_id=0):
self.infer_params = dict(**self.pipeline_manager.module_params)
self.send_image(input_images_dir, task_id)

def fetch_result(self):
return self.pipeline_manager.fetch_result()

def send_image(self, images: str, task_id):
def send_image(self, images: str, task_id=0):
"""
send image to input queue for pipeline
"""
Expand Down Expand Up @@ -61,7 +61,7 @@ def _send_batch_image(self, images, batch_num, task_id):
else:
self.input_queue.put([[images], (1, task_id)], block=True)

def infer_for_array(self, input_array, task_id):
def infer_for_array(self, input_array, task_id=0):
self.infer_params = dict(**self.pipeline_manager.module_params)
self.send_array(input_array, task_id)

Expand Down
2 changes: 1 addition & 1 deletion deploy/py_infer/src/utils/adapted/mindocr_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

MINDOCR_MODELS = {
"en_ms_det_dbnet_resnet50": "det/dbnet/db_r50_icdar15.yaml",
"en_ms_det_dbnetpp_resnet50": "det/dbnet/db++_r50_icdar15.yaml",
"en_ms_det_dbnetpp_resnet50": "det/dbnet/dbpp_r50_icdar15.yaml",
"en_ms_det_psenet_resnet152": "det/psenet/pse_r152_icdar15.yaml",
"en_ms_det_psenet_resnet50": "det/psenet/pse_r50_icdar15.yaml",
"en_ms_det_psenet_mobilenetv3": "det/psenet/pse_mv3_icdar15.yaml",
Expand Down
2 changes: 1 addition & 1 deletion docs/cn/datasets/synthtext.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ path-to-data-dir/

> :warning: 另外, 我们强烈建议在使用 `SynthText` 数据集之前先进行预处理,因为它包含一些错误的数据。可以使用下列的方式进行校正:
> ```shell
> python tools/dataset_converters/convert.py --dataset_name=synthtext --task=det --label_dir=/path-to-data-dir/SynthText/gt.mat --output_path=/path-to-data-dir/SynthText/gt_processed.mat
> python tools/dataset_converters/convert.py --dataset_name=synthtext --task=det --label_dir=/path-to-data-dir/SynthText/gt.mat --output_path=/path-to-data-dir/SynthText/gt_processed.mat --image_dir=/path-to-data-dir/SynthText
> ```
> 以上的操作会产生与`SynthText`原始标注格式相同但是是经过过滤后的标注数据.

Expand Down
4 changes: 2 additions & 2 deletions docs/cn/inference/inference_quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
| | ResNet-18 | en | IC15 | 81.73 | 24.04 | (1,3,736,1280) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet/db_r18_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet18-0c0c4cfa.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet18-0c0c4cfa-cf46eb8b.mindir) |
| | ResNet-50 | en | IC15 | 85.00 | 21.69 | (1,3,736,1280) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet/db_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50-c3a4aa24.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50-c3a4aa24-fbf95c82.mindir) |
| | ResNet-50 | ch + en | 12个数据集 | 83.41 | 21.69 | (1,3,736,1280) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet/db_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50_ch_en_general-a5dbb141.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50_ch_en_general-a5dbb141-912f0a90.mindir) |
| [DBNet++](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet) | ResNet-50 | en | IC15 | 86.79 | 8.46 | (1,3,1152,2048) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet/db++_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2-9934aff0.mindir) |
| | ResNet-50 | ch + en | 12个数据集 | 84.30 | 8.46 | (1,3,1152,2048) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet/db++_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_ch_en_general-884ba5b9.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_ch_en_general-884ba5b9-b3f52398.mindir) |
| [DBNet++](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet) | ResNet-50 | en | IC15 | 86.79 | 8.46 | (1,3,1152,2048) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet/dbpp_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50-068166c2-9934aff0.mindir) |
| | ResNet-50 | ch + en | 12个数据集 | 84.30 | 8.46 | (1,3,1152,2048) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/dbnet/dbpp_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_ch_en_general-884ba5b9.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnetpp_resnet50_ch_en_general-884ba5b9-b3f52398.mindir) |
| [EAST](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/east) | ResNet-50 | en | IC15 | 86.86 | 6.72 | (1,3,720,1280) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/east/east_r50_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/east/east_resnet50_ic15-7262e359.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/east/east_resnet50_ic15-7262e359-5f05cd42.mindir) |
| | MobileNetV3 | en | IC15 | 75.32 | 26.77 | (1,3,720,1280) | [yaml](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/east/east_mobilenetv3_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/east/east_mobilenetv3_ic15-4288dba1.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/east/east_mobilenetv3_ic15-4288dba1-5bf242c5.mindir) |
| [PSENet](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/psenet) | ResNet-152 | en | IC15 | 82.50 | 2.52 | (1,3,1472,2624) | [yaml](https://github.com/mindspore-lab/mindocr/tree/main/configs/det/psenet/pse_r152_icdar15.yaml) | [ckpt](https://download.mindspore.cn/toolkits/mindocr/psenet/psenet_resnet152_ic15-6058a798.ckpt) \| [mindir](https://download.mindspore.cn/toolkits/mindocr/psenet/psenet_resnet152_ic15-6058a798-0d755205.mindir) |
Expand Down
2 changes: 1 addition & 1 deletion docs/en/datasets/synthtext.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ path-to-data-dir/

> :warning: Additionally, It is strongly recommended to pre-process the `SynthText` dataset before using it as it contains some faulty data:
> ```shell
> python tools/dataset_converters/convert.py --dataset_name=synthtext --task=det --label_dir=/path-to-data-dir/SynthText/gt.mat --output_path=/path-to-data-dir/SynthText/gt_processed.mat
> python tools/dataset_converters/convert.py --dataset_name=synthtext --task=det --label_dir=/path-to-data-dir/SynthText/gt.mat --output_path=/path-to-data-dir/SynthText/gt_processed.mat --image_dir=/path-to-data-dir/SynthText
> ```
> This operation will generate a filtered output in the same format as the original `SynthText`.

Expand Down
Loading