diff --git a/cv/ocr/dbnet/pytorch/EGG-INFO/PKG-INFO b/cv/ocr/dbnet/pytorch/EGG-INFO/PKG-INFO
index 9280d7ec8910f9759c9d8490c4df803cfb4e7583..79f2331b13ebd593f5c6410a4172ab20f6518162 100755
--- a/cv/ocr/dbnet/pytorch/EGG-INFO/PKG-INFO
+++ b/cv/ocr/dbnet/pytorch/EGG-INFO/PKG-INFO
@@ -1,9 +1,9 @@
Metadata-Version: 2.1
-Name: dbnet_det
+Name: mmdet
Version: 2.25.0
Summary: OpenMMLab Detection Toolbox and Benchmark
-Home-page: https://github.com/open-mmlab/dbnet_detection
-Author: dbnet_detection Contributors
+Home-page: https://github.com/open-mmlab/mmdetection
+Author: MMDetection Contributors
Author-email: openmmlab@gmail.com
License: Apache License 2.0
Keywords: computer vision,object detection
@@ -22,7 +22,7 @@ Provides-Extra: build
Provides-Extra: optional
-

+
OpenMMLab website
@@ -41,20 +41,20 @@ Provides-Extra: optional
-[](https://pypi.org/project/dbnet_det)
-[](https://dbnet_detection.readthedocs.io/en/latest/)
-[](https://github.com/open-mmlab/dbnet_detection/actions)
-[](https://codecov.io/gh/open-mmlab/dbnet_detection)
-[](https://github.com/open-mmlab/dbnet_detection/blob/master/LICENSE)
-[](https://github.com/open-mmlab/dbnet_detection/issues)
-[](https://github.com/open-mmlab/dbnet_detection/issues)
-
-[📘Documentation](https://dbnet_detection.readthedocs.io/en/stable/) |
-[🛠️Installation](https://dbnet_detection.readthedocs.io/en/stable/get_started.html) |
-[👀Model Zoo](https://dbnet_detection.readthedocs.io/en/stable/model_zoo.html) |
-[🆕Update News](https://dbnet_detection.readthedocs.io/en/stable/changelog.html) |
-[🚀Ongoing Projects](https://github.com/open-mmlab/dbnet_detection/projects) |
-[🤔Reporting Issues](https://github.com/open-mmlab/dbnet_detection/issues/new/choose)
+[](https://pypi.org/project/mmdet)
+[](https://mmdetection.readthedocs.io/en/latest/)
+[](https://github.com/open-mmlab/mmdetection/actions)
+[](https://codecov.io/gh/open-mmlab/mmdetection)
+[](https://github.com/open-mmlab/mmdetection/blob/master/LICENSE)
+[](https://github.com/open-mmlab/mmdetection/issues)
+[](https://github.com/open-mmlab/mmdetection/issues)
+
+[📘Documentation](https://mmdetection.readthedocs.io/en/stable/) |
+[🛠️Installation](https://mmdetection.readthedocs.io/en/stable/get_started.html) |
+[👀Model Zoo](https://mmdetection.readthedocs.io/en/stable/model_zoo.html) |
+[🆕Update News](https://mmdetection.readthedocs.io/en/stable/changelog.html) |
+[🚀Ongoing Projects](https://github.com/open-mmlab/mmdetection/projects) |
+[🤔Reporting Issues](https://github.com/open-mmlab/mmdetection/issues/new/choose)
@@ -66,7 +66,7 @@ English | [简体中文](README_zh-CN.md)
## Introduction
-dbnet_detection is an open source object detection toolbox based on PyTorch. It is
+MMDetection is an open source object detection toolbox based on PyTorch. It is
a part of the [OpenMMLab](https://openmmlab.com/) project.
The master branch works with **PyTorch 1.5+**.
@@ -90,7 +90,7 @@ The master branch works with **PyTorch 1.5+**.
- **State of the art**
- The toolbox stems from the codebase developed by the *dbnet_det* team, who won [COCO Detection Challenge](http://cocodataset.org/#detection-leaderboard) in 2018, and we keep pushing it forward.
+ The toolbox stems from the codebase developed by the *MMDet* team, who won [COCO Detection Challenge](http://cocodataset.org/#detection-leaderboard) in 2018, and we keep pushing it forward.
@@ -100,14 +100,14 @@ Apart from dbnet_detection, we also released a library [dbnet_cv](https://github
**2.25.0** was released in 1/6/2022:
-- Support dedicated `dbnet_detWandbHook` hook
+- Support dedicated `MMDetWandbHook` hook
- Support [ConvNeXt](configs/convnext), [DDOD](configs/ddod), [SOLOv2](configs/solov2)
- Support [Mask2Former](configs/mask2former) for instance segmentation
- Rename [config files of Mask2Former](configs/mask2former)
Please refer to [changelog.md](docs/en/changelog.md) for details and release history.
-For compatibility changes between different versions of dbnet_detection, please refer to [compatibility.md](docs/en/compatibility.md).
+For compatibility changes between different versions of MMDetection, please refer to [compatibility.md](docs/en/compatibility.md).
## Installation
@@ -115,7 +115,7 @@ Please refer to [Installation](docs/en/get_started.md/#Installation) for install
## Getting Started
-Please see [get_started.md](docs/en/get_started.md) for the basic usage of dbnet_detection. We provide [colab tutorial](demo/dbnet_det_Tutorial.ipynb) and [instance segmentation colab tutorial](demo/dbnet_det_InstanceSeg_Tutorial.ipynb), and other tutorials for:
+Please see [get_started.md](docs/en/get_started.md) for the basic usage of MMDetection. We provide [colab tutorial](demo/MMDet_Tutorial.ipynb) and [instance segmentation colab tutorial](demo/MMDet_InstanceSeg_Tutorial.ipynb), and other tutorials for:
- [with existing dataset](docs/en/1_exist_data_model.md)
- [with new dataset](docs/en/2_new_data_model.md)
@@ -320,7 +320,7 @@ Results and models are available in the [model zoo](docs/en/model_zoo.md).
-Some other methods are also supported in [projects using dbnet_detection](./docs/en/projects.md).
+Some other methods are also supported in [projects using MMDetection](./docs/en/projects.md).
## FAQ
@@ -328,11 +328,11 @@ Please refer to [FAQ](docs/en/faq.md) for frequently asked questions.
## Contributing
-We appreciate all contributions to improve dbnet_detection. Ongoing projects can be found in out [GitHub Projects](https://github.com/open-mmlab/dbnet_detection/projects). Welcome community users to participate in these projects. Please refer to [CONTRIBUTING.md](.github/CONTRIBUTING.md) for the contributing guideline.
+We appreciate all contributions to improve MMDetection. Ongoing projects can be found in out [GitHub Projects](https://github.com/open-mmlab/mmdetection/projects). Welcome community users to participate in these projects. Please refer to [CONTRIBUTING.md](.github/CONTRIBUTING.md) for the contributing guideline.
## Acknowledgement
-dbnet_detection is an open source project that is contributed by researchers and engineers from various colleges and companies. We appreciate all the contributors who implement their methods or add new features, as well as users who give valuable feedbacks.
+MMDetection is an open source project that is contributed by researchers and engineers from various colleges and companies. We appreciate all the contributors who implement their methods or add new features, as well as users who give valuable feedbacks.
We wish that the toolbox and benchmark could serve the growing research community by providing a flexible toolkit to reimplement existing methods and develop their own new detectors.
## Citation
@@ -340,8 +340,8 @@ We wish that the toolbox and benchmark could serve the growing research communit
If you use this toolbox or benchmark in your research, please cite this project.
```
-@article{dbnet_detection,
- title = {{dbnet_detection}: Open MMLab Detection Toolbox and Benchmark},
+@article{mmdetection,
+ title = {{MMDetection}: Open MMLab Detection Toolbox and Benchmark},
author = {Chen, Kai and Wang, Jiaqi and Pang, Jiangmiao and Cao, Yuhang and
Xiong, Yu and Li, Xiaoxiao and Sun, Shuyang and Feng, Wansen and
Liu, Ziwei and Xu, Jiarui and Zhang, Zheng and Cheng, Dazhi and
@@ -362,8 +362,8 @@ This project is released under the [Apache 2.0 license](LICENSE).
- [DBNET_CV](https://github.com/open-mmlab/dbnet_cv): OpenMMLab foundational library for computer vision.
- [MIM](https://github.com/open-mmlab/mim): MIM installs OpenMMLab packages.
- [MMClassification](https://github.com/open-mmlab/mmclassification): OpenMMLab image classification toolbox and benchmark.
-- [dbnet_detection](https://github.com/open-mmlab/dbnet_detection): OpenMMLab detection toolbox and benchmark.
-- [dbnet_detection3D](https://github.com/open-mmlab/dbnet_detection3d): OpenMMLab's next-generation platform for general 3D object detection.
+- [MMDetection](https://github.com/open-mmlab/mmdetection): OpenMMLab detection toolbox and benchmark.
+- [MMDetection3D](https://github.com/open-mmlab/mmdetection3d): OpenMMLab's next-generation platform for general 3D object detection.
- [MMRotate](https://github.com/open-mmlab/mmrotate): OpenMMLab rotated object detection toolbox and benchmark.
- [MMSegmentation](https://github.com/open-mmlab/mmsegmentation): OpenMMLab semantic segmentation toolbox and benchmark.
- [MMOCR](https://github.com/open-mmlab/mmocr): OpenMMLab text detection, recognition, and understanding toolbox.
diff --git a/cv/ocr/dbnet/pytorch/EGG-INFO/SOURCES.txt b/cv/ocr/dbnet/pytorch/EGG-INFO/SOURCES.txt
index 4f42864d415c099c85025f0159e89eb707bdcd5e..5c2591de8c715350818398a9bc8325c87d61d36c 100755
--- a/cv/ocr/dbnet/pytorch/EGG-INFO/SOURCES.txt
+++ b/cv/ocr/dbnet/pytorch/EGG-INFO/SOURCES.txt
@@ -1,62 +1,62 @@
README.md
setup.py
-dbnet_det/__init__.py
-dbnet_det/version.py
-dbnet_det.egg-info/PKG-INFO
-dbnet_det.egg-info/SOURCES.txt
-dbnet_det.egg-info/dependency_links.txt
-dbnet_det.egg-info/not-zip-safe
-dbnet_det.egg-info/requires.txt
-dbnet_det.egg-info/top_level.txt
-dbnet_det/core/__init__.py
-dbnet_det/core/bbox/__init__.py
-dbnet_det/core/bbox/transforms.py
-dbnet_det/core/evaluation/__init__.py
-dbnet_det/core/evaluation/bbox_overlaps.py
-dbnet_det/core/evaluation/class_names.py
-dbnet_det/core/evaluation/eval_hooks.py
-dbnet_det/core/evaluation/mean_ap.py
-dbnet_det/core/evaluation/panoptic_utils.py
-dbnet_det/core/evaluation/recall.py
-dbnet_det/core/mask/__init__.py
-dbnet_det/core/mask/structures.py
-dbnet_det/core/mask/utils.py
-dbnet_det/core/utils/__init__.py
-dbnet_det/core/utils/dist_utils.py
-dbnet_det/core/utils/misc.py
-dbnet_det/core/visualization/__init__.py
-dbnet_det/core/visualization/image.py
-dbnet_det/core/visualization/palette.py
-dbnet_det/datasets/__init__.py
-dbnet_det/datasets/builder.py
-dbnet_det/datasets/coco.py
-dbnet_det/datasets/custom.py
-dbnet_det/datasets/dataset_wrappers.py
-dbnet_det/datasets/utils.py
-dbnet_det/datasets/api_wrappers/__init__.py
-dbnet_det/datasets/api_wrappers/coco_api.py
-dbnet_det/datasets/api_wrappers/panoptic_evaluation.py
-dbnet_det/datasets/pipelines/__init__.py
-dbnet_det/datasets/pipelines/compose.py
-dbnet_det/datasets/pipelines/formatting.py
-dbnet_det/datasets/pipelines/loading.py
-dbnet_det/datasets/pipelines/test_time_aug.py
-dbnet_det/datasets/pipelines/transforms.py
-dbnet_det/datasets/samplers/__init__.py
-dbnet_det/datasets/samplers/class_aware_sampler.py
-dbnet_det/datasets/samplers/distributed_sampler.py
-dbnet_det/datasets/samplers/group_sampler.py
-dbnet_det/datasets/samplers/infinite_sampler.py
-dbnet_det/models/__init__.py
-dbnet_det/models/builder.py
-dbnet_det/models/backbones/__init__.py
-dbnet_det/models/backbones/resnet.py
-dbnet_det/models/detectors/__init__.py
-dbnet_det/models/detectors/base.py
-dbnet_det/models/detectors/single_stage.py
-dbnet_det/models/utils/__init__.py
-dbnet_det/models/utils/res_layer.py
-dbnet_det/utils/__init__.py
-dbnet_det/utils/logger.py
-dbnet_det/utils/profiling.py
-dbnet_det/utils/util_distribution.py
\ No newline at end of file
+mmdet/__init__.py
+mmdet/version.py
+mmdet.egg-info/PKG-INFO
+mmdet.egg-info/SOURCES.txt
+mmdet.egg-info/dependency_links.txt
+mmdet.egg-info/not-zip-safe
+mmdet.egg-info/requires.txt
+mmdet.egg-info/top_level.txt
+mmdet/core/__init__.py
+mmdet/core/bbox/__init__.py
+mmdet/core/bbox/transforms.py
+mmdet/core/evaluation/__init__.py
+mmdet/core/evaluation/bbox_overlaps.py
+mmdet/core/evaluation/class_names.py
+mmdet/core/evaluation/eval_hooks.py
+mmdet/core/evaluation/mean_ap.py
+mmdet/core/evaluation/panoptic_utils.py
+mmdet/core/evaluation/recall.py
+mmdet/core/mask/__init__.py
+mmdet/core/mask/structures.py
+mmdet/core/mask/utils.py
+mmdet/core/utils/__init__.py
+mmdet/core/utils/dist_utils.py
+mmdet/core/utils/misc.py
+mmdet/core/visualization/__init__.py
+mmdet/core/visualization/image.py
+mmdet/core/visualization/palette.py
+mmdet/datasets/__init__.py
+mmdet/datasets/builder.py
+mmdet/datasets/coco.py
+mmdet/datasets/custom.py
+mmdet/datasets/dataset_wrappers.py
+mmdet/datasets/utils.py
+mmdet/datasets/api_wrappers/__init__.py
+mmdet/datasets/api_wrappers/coco_api.py
+mmdet/datasets/api_wrappers/panoptic_evaluation.py
+mmdet/datasets/pipelines/__init__.py
+mmdet/datasets/pipelines/compose.py
+mmdet/datasets/pipelines/formatting.py
+mmdet/datasets/pipelines/loading.py
+mmdet/datasets/pipelines/test_time_aug.py
+mmdet/datasets/pipelines/transforms.py
+mmdet/datasets/samplers/__init__.py
+mmdet/datasets/samplers/class_aware_sampler.py
+mmdet/datasets/samplers/distributed_sampler.py
+mmdet/datasets/samplers/group_sampler.py
+mmdet/datasets/samplers/infinite_sampler.py
+mmdet/models/__init__.py
+mmdet/models/builder.py
+mmdet/models/backbones/__init__.py
+mmdet/models/backbones/resnet.py
+mmdet/models/detectors/__init__.py
+mmdet/models/detectors/base.py
+mmdet/models/detectors/single_stage.py
+mmdet/models/utils/__init__.py
+mmdet/models/utils/res_layer.py
+mmdet/utils/__init__.py
+mmdet/utils/logger.py
+mmdet/utils/profiling.py
+mmdet/utils/util_distribution.py
\ No newline at end of file
diff --git a/cv/ocr/dbnet/pytorch/EGG-INFO/top_level.txt b/cv/ocr/dbnet/pytorch/EGG-INFO/top_level.txt
index 2d2f43c40746f3804a679a386877c3d40e319f48..95688066ccb562455a4cd93e8007c7118d68ef9c 100755
--- a/cv/ocr/dbnet/pytorch/EGG-INFO/top_level.txt
+++ b/cv/ocr/dbnet/pytorch/EGG-INFO/top_level.txt
@@ -1 +1 @@
-dbnet_det
+mmdet
diff --git a/cv/ocr/dbnet/pytorch/configs/_base_/det_datasets/icdar2015.py b/cv/ocr/dbnet/pytorch/configs/_base_/det_datasets/icdar2015.py
index f711c06dce76d53b8737288c8de318e6f90ce585..6e14ae22270be238a43db707c817f15a67e1efd7 100755
--- a/cv/ocr/dbnet/pytorch/configs/_base_/det_datasets/icdar2015.py
+++ b/cv/ocr/dbnet/pytorch/configs/_base_/det_datasets/icdar2015.py
@@ -1,5 +1,7 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
dataset_type = 'IcdarDataset'
-data_root = 'data/icdar2015'
+data_root = 'OCR_Detect'
train = dict(
type=dataset_type,
diff --git a/cv/ocr/dbnet/pytorch/configs/_base_/det_models/dbnet_r18_fpnc.py b/cv/ocr/dbnet/pytorch/configs/_base_/det_models/dbnet_r18_fpnc.py
index b26391f4d4b2eb34beae81cce56c2816979bc730..4d9fa24e17c477a9b4d79726d50094def033d872 100755
--- a/cv/ocr/dbnet/pytorch/configs/_base_/det_models/dbnet_r18_fpnc.py
+++ b/cv/ocr/dbnet/pytorch/configs/_base_/det_models/dbnet_r18_fpnc.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
model = dict(
type='DBNet',
backbone=dict(
@@ -15,17 +17,7 @@ model = dict(
bbox_head=dict(
type='DBHead',
in_channels=256,
- loss=dict(type='DBLoss', alpha=5.0, beta=10.0, bbce_loss=False),
+ loss=dict(type='DBLoss', alpha=5.0, beta=10.0, bbce_loss=True),
postprocessor=dict(type='DBPostprocessor', text_repr_type='quad')),
train_cfg=None,
test_cfg=None)
-
-
-
-# backbone=dict(
-# type='MobileNetV3',
-# arch='small',
-# out_indices=(0, 1, 12),
-# norm_cfg=dict(type='BN', requires_grad=True),
-# init_cfg=dict(type='Pretrained', checkpoint='open-mmlab://contrib/mobilenet_v3_small')
-# ),
\ No newline at end of file
diff --git a/cv/ocr/dbnet/pytorch/configs/_base_/det_pipelines/dbnet_pipeline.py b/cv/ocr/dbnet/pytorch/configs/_base_/det_pipelines/dbnet_pipeline.py
index aeb944871ac6d12bf5fc9a694076942afa63a7d8..cd0433641cb2bee4a1e2563158ee4259182991d7 100755
--- a/cv/ocr/dbnet/pytorch/configs/_base_/det_pipelines/dbnet_pipeline.py
+++ b/cv/ocr/dbnet/pytorch/configs/_base_/det_pipelines/dbnet_pipeline.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
@@ -30,7 +32,7 @@ test_pipeline_1333_736 = [
dict(type='LoadImageFromFile', color_type='color_ignore_orientation'),
dict(
type='MultiScaleFlipAug',
- img_scale=(1280, 736), # used by Resize
+ img_scale=(1333, 736), # used by Resize
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
diff --git a/cv/ocr/dbnet/pytorch/configs/textdet/dbnet/dbnet_r18_fpnc_1200e_icdar2015.py b/cv/ocr/dbnet/pytorch/configs/textdet/dbnet/dbnet_r18_fpnc_1200e_icdar2015.py
index 9ea1bcc18a63fbdc1bd118932d605eaf9badb008..40ca14bc321aaae495dcf72056b11303f52ec8b8 100755
--- a/cv/ocr/dbnet/pytorch/configs/textdet/dbnet/dbnet_r18_fpnc_1200e_icdar2015.py
+++ b/cv/ocr/dbnet/pytorch/configs/textdet/dbnet/dbnet_r18_fpnc_1200e_icdar2015.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
_base_ = [
'../../_base_/default_runtime.py',
'../../_base_/schedules/schedule_sgd_1200e.py',
@@ -29,5 +31,5 @@ data = dict(
type='UniformConcatDataset',
datasets=test_list,
pipeline=test_pipeline_1333_736))
-fp16 = dict(loss_scale='dynamic')
+
evaluation = dict(interval=100, metric='hmean-iou')
diff --git a/cv/ocr/dbnet/pytorch/configs/textdet/dbnet/dbnet_r50dcnv2_fpnc_1200e_icdar2015.py b/cv/ocr/dbnet/pytorch/configs/textdet/dbnet/dbnet_r50dcnv2_fpnc_1200e_icdar2015.py
index 06e2545b830fa710c2d641892b56bc0e69b13aa8..a7eee5a97733a22c056e6cc10226af27952a55ea 100755
--- a/cv/ocr/dbnet/pytorch/configs/textdet/dbnet/dbnet_r50dcnv2_fpnc_1200e_icdar2015.py
+++ b/cv/ocr/dbnet/pytorch/configs/textdet/dbnet/dbnet_r50dcnv2_fpnc_1200e_icdar2015.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
_base_ = [
'../../_base_/default_runtime.py',
'../../_base_/schedules/schedule_sgd_1200e.py',
@@ -13,7 +15,6 @@ train_pipeline_r50dcnv2 = {{_base_.train_pipeline_r50dcnv2}}
test_pipeline_4068_1024 = {{_base_.test_pipeline_4068_1024}}
# load_from = 'checkpoints/textdet/dbnet/res50dcnv2_synthtext.pth'
-# fp16 = dict(loss_scale='dynamic')
data = dict(
samples_per_gpu=8,
@@ -32,6 +33,5 @@ data = dict(
type='UniformConcatDataset',
datasets=test_list,
pipeline=test_pipeline_4068_1024))
-fp16 = dict(loss_scale='dynamic')
-evaluation = dict(interval=1, metric='hmean-iou')
-# fp16 = dict(loss_scale='dynamic')
+
+evaluation = dict(interval=100, metric='hmean-iou')
diff --git a/cv/ocr/dbnet/pytorch/dbnet/apis/train.py b/cv/ocr/dbnet/pytorch/dbnet/apis/train.py
index e1008be26014eb0b96f18904a104416c162cd492..6532a5320f16ba12377a81e11996e1c6ca3c96f0 100755
--- a/cv/ocr/dbnet/pytorch/dbnet/apis/train.py
+++ b/cv/ocr/dbnet/pytorch/dbnet/apis/train.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import warnings
@@ -171,7 +173,7 @@ def init_random_seed(seed=None, device='cuda'):
# Make sure all ranks share the same random seed to prevent
# some potential bugs. Please refer to
- # https://github.com/open-mmlab/dbnet_detection/issues/6339
+ # https://github.com/open-mmlab/mmdetection/issues/6339
rank, world_size = get_dist_info()
seed = np.random.randint(2**31)
if world_size == 1:
diff --git a/cv/ocr/dbnet/pytorch/dbnet/datasets/icdar_dataset.py b/cv/ocr/dbnet/pytorch/dbnet/datasets/icdar_dataset.py
index f18cece80bc1a400c23009b65fda3652f3a0b14f..5881a2c9192eac960b4a19314017a6cce95768ca 100755
--- a/cv/ocr/dbnet/pytorch/dbnet/datasets/icdar_dataset.py
+++ b/cv/ocr/dbnet/pytorch/dbnet/datasets/icdar_dataset.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import dbnet_cv
import numpy as np
@@ -40,7 +42,7 @@ class IcdarDataset(CocoDataset):
super().__init__(ann_file, pipeline, classes, data_root, img_prefix,
seg_prefix, proposal_file, test_mode, filter_empty_gt)
- # Set dummy flags just to be compatible with dbnet_det
+ # Set dummy flags just to be compatible with MMDet
self.flag = np.zeros(len(self), dtype=np.uint8)
def load_annotations(self, ann_file):
diff --git a/cv/ocr/dbnet/pytorch/dbnet/datasets/pipelines/transforms.py b/cv/ocr/dbnet/pytorch/dbnet/datasets/pipelines/transforms.py
index e4a7a08ff976356fc76154349d530aaad3bfeb85..fd2dd62836747efd0c85f6495ce8d3dd7bd7bb18 100755
--- a/cv/ocr/dbnet/pytorch/dbnet/datasets/pipelines/transforms.py
+++ b/cv/ocr/dbnet/pytorch/dbnet/datasets/pipelines/transforms.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import math
@@ -226,7 +228,7 @@ class RandomRotateTextDet:
@PIPELINES.register_module()
class ColorJitter:
"""An interface for torch color jitter so that it can be invoked in
- dbnet_detection pipeline."""
+ mmdetection pipeline."""
def __init__(self, **kwargs):
self.transform = transforms.ColorJitter(**kwargs)
@@ -338,7 +340,7 @@ class ScaleAspectJitter(Resize):
@PIPELINES.register_module()
class AffineJitter:
"""An interface for torchvision random affine so that it can be invoked in
- dbnet_det pipeline."""
+ mmdet pipeline."""
def __init__(self,
degrees=4,
diff --git a/cv/ocr/dbnet/pytorch/dbnet/models/builder.py b/cv/ocr/dbnet/pytorch/dbnet/models/builder.py
index d5a1963674671aed82fcbec3e77c2cc7827d5057..b2e3cdc65d3f889707c199d2294f36779fda581b 100755
--- a/cv/ocr/dbnet/pytorch/dbnet/models/builder.py
+++ b/cv/ocr/dbnet/pytorch/dbnet/models/builder.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import warnings
@@ -5,7 +7,7 @@ import torch.nn as nn
from dbnet_cv.cnn import ACTIVATION_LAYERS as DBNET_CV_ACTIVATION_LAYERS
from dbnet_cv.cnn import UPSAMPLE_LAYERS as DBNET_CV_UPSAMPLE_LAYERS
from dbnet_cv.utils import Registry, build_from_cfg
-from dbnet_det.models.builder import BACKBONES as dbnet_det_BACKBONES
+from dbnet_det.models.builder import BACKBONES as MMDET_BACKBONES
CONVERTORS = Registry('convertor')
ENCODERS = Registry('encoder')
@@ -14,7 +16,7 @@ PREPROCESSOR = Registry('preprocessor')
POSTPROCESSOR = Registry('postprocessor')
UPSAMPLE_LAYERS = Registry('upsample layer', parent=DBNET_CV_UPSAMPLE_LAYERS)
-BACKBONES = Registry('models', parent=dbnet_det_BACKBONES)
+BACKBONES = Registry('models', parent=MMDET_BACKBONES)
LOSSES = BACKBONES
DETECTORS = BACKBONES
ROI_EXTRACTORS = BACKBONES
diff --git a/cv/ocr/dbnet/pytorch/dbnet/models/common/detectors/single_stage.py b/cv/ocr/dbnet/pytorch/dbnet/models/common/detectors/single_stage.py
index dad1d98bcff9825d9e2205c0c72e06e7c5c14e77..8408ead5c3e16881242d85e30f2068f77d75d2c6 100755
--- a/cv/ocr/dbnet/pytorch/dbnet/models/common/detectors/single_stage.py
+++ b/cv/ocr/dbnet/pytorch/dbnet/models/common/detectors/single_stage.py
@@ -1,15 +1,17 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import warnings
from dbnet_det.models.detectors import \
- SingleStageDetector as dbnet_det_SingleStageDetector
+ SingleStageDetector as MMDET_SingleStageDetector
from dbnet.models.builder import (DETECTORS, build_backbone, build_head,
build_neck)
@DETECTORS.register_module()
-class SingleStageDetector(dbnet_det_SingleStageDetector):
+class SingleStageDetector(MMDET_SingleStageDetector):
"""Base class for single-stage detectors.
Single-stage detectors directly and densely predict bounding boxes on the
@@ -24,7 +26,7 @@ class SingleStageDetector(dbnet_det_SingleStageDetector):
test_cfg=None,
pretrained=None,
init_cfg=None):
- super(dbnet_det_SingleStageDetector, self).__init__(init_cfg=init_cfg)
+ super(MMDET_SingleStageDetector, self).__init__(init_cfg=init_cfg)
if pretrained:
warnings.warn('DeprecationWarning: pretrained is deprecated, '
'please use "init_cfg" instead')
diff --git a/cv/ocr/dbnet/pytorch/dbnet/models/textdet/detectors/single_stage_text_detector.py b/cv/ocr/dbnet/pytorch/dbnet/models/textdet/detectors/single_stage_text_detector.py
index 8b2b28a8f0eb8c84ff2266af2fd14dd0675d6bf2..d42abfa5cf8db73fe937bb8d038bebb67d2de89d 100755
--- a/cv/ocr/dbnet/pytorch/dbnet/models/textdet/detectors/single_stage_text_detector.py
+++ b/cv/ocr/dbnet/pytorch/dbnet/models/textdet/detectors/single_stage_text_detector.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import torch
@@ -29,7 +31,7 @@ class SingleStageTextDetector(SingleStageDetector):
has: 'img_shape', 'scale_factor', 'flip', and may also contain
'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.
For details on the values of these keys, see
- :class:`dbnet_det.datasets.pipelines.Collect`.
+ :class:`mmdet.datasets.pipelines.Collect`.
Returns:
dict[str, Tensor]: A dictionary of loss components.
"""
diff --git a/cv/ocr/dbnet/pytorch/dbnet/models/textdet/losses/db_loss.py b/cv/ocr/dbnet/pytorch/dbnet/models/textdet/losses/db_loss.py
index b9c32ef579ae030f568a964fcb630eebeb1511cb..4dc0a69e554028d90e12d24cb78516db8c29a255 100755
--- a/cv/ocr/dbnet/pytorch/dbnet/models/textdet/losses/db_loss.py
+++ b/cv/ocr/dbnet/pytorch/dbnet/models/textdet/losses/db_loss.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn.functional as F
@@ -88,8 +90,7 @@ class DBLoss(nn.Module):
assert gt.max() <= 1 and gt.min() >= 0
assert pred.max() <= 1 and pred.min() >= 0
-
- loss = F.binary_cross_entropy_with_logits(pred, gt, reduction='none')
+ loss = F.binary_cross_entropy(pred, gt, reduction='none')
positive_loss = loss * positive.float()
negative_loss = loss * negative.float()
diff --git a/cv/ocr/dbnet/pytorch/dbnet_cv/cnn/bricks/__init__.py b/cv/ocr/dbnet/pytorch/dbnet_cv/cnn/bricks/__init__.py
index d1e17d38c9c54a084b995ce69ab27ed993788c49..524d11491133713d508815ca3b2e2dcdf65b0eb0 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_cv/cnn/bricks/__init__.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_cv/cnn/bricks/__init__.py
@@ -1,17 +1,17 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from .activation import build_activation_layer
from .conv import build_conv_layer
from .conv_module import ConvModule
-from .conv2d_adaptive_padding import Conv2dAdaptivePadding
+
from .norm import build_norm_layer, is_norm
from .padding import build_padding_layer
from .plugin import build_plugin_layer
-from .drop import Dropout, DropPath
from .registry import (ACTIVATION_LAYERS, CONV_LAYERS, NORM_LAYERS,
PADDING_LAYERS, PLUGIN_LAYERS, UPSAMPLE_LAYERS)
-from .hsigmoid import HSigmoid
-from .hswish import HSwish
+
from .upsample import build_upsample_layer
from .wrappers import (Conv2d, Conv3d, ConvTranspose2d, ConvTranspose3d,
Linear, MaxPool2d, MaxPool3d)
diff --git a/cv/ocr/dbnet/pytorch/dbnet_cv/cnn/utils/weight_init.py b/cv/ocr/dbnet/pytorch/dbnet_cv/cnn/utils/weight_init.py
index 8ed99109e73aeef2e618ed14f0dab33bf446faaa..8d779cc9eb320f6a6b7c00779323f9f16a7a1993 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_cv/cnn/utils/weight_init.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_cv/cnn/utils/weight_init.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import math
@@ -613,7 +615,7 @@ def initialize(module: nn.Module, init_cfg: Union[Dict, List[dict]]) -> None:
>>> # Initialize weights of a sub-module with the specific part of
>>> # a pretrained model by using "prefix".
- >>> url = 'http://download.openmmlab.com/dbnet_detection/v2.0/retinanet/'\
+ >>> url = 'http://download.openmmlab.com/mmdetection/v2.0/retinanet/'\
>>> 'retinanet_r50_fpn_1x_coco/'\
>>> 'retinanet_r50_fpn_1x_coco_20200130-c2398f9e.pth'
>>> init_cfg = dict(type='Pretrained',
diff --git a/cv/ocr/dbnet/pytorch/dbnet_cv/model_zoo/open_mmlab.json b/cv/ocr/dbnet/pytorch/dbnet_cv/model_zoo/open_mmlab.json
index a2a0772ef3511694e4fb8b11349c264e8d41b4d7..8311db4feef92faa0841c697d75efbee8430c3a0 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_cv/model_zoo/open_mmlab.json
+++ b/cv/ocr/dbnet/pytorch/dbnet_cv/model_zoo/open_mmlab.json
@@ -25,7 +25,7 @@
"bninception_caffe": "https://download.openmmlab.com/pretrain/third_party/bn_inception_caffe-ed2e8665.pth",
"kin400/i3d_r50_f32s2_k400": "https://download.openmmlab.com/pretrain/third_party/i3d_r50_f32s2_k400-2c57e077.pth",
"kin400/nl3d_r50_f32s2_k400": "https://download.openmmlab.com/pretrain/third_party/nl3d_r50_f32s2_k400-fa7e7caa.pth",
- "res2net101_v1d_26w_4s": "https://download.openmmlab.com/pretrain/third_party/res2net101_v1d_26w_4s_dbnet_detv2-f0a600f9.pth",
+ "res2net101_v1d_26w_4s": "https://download.openmmlab.com/pretrain/third_party/res2net101_v1d_26w_4s_mmdetv2-f0a600f9.pth",
"regnetx_400mf": "https://download.openmmlab.com/pretrain/third_party/regnetx_400mf-a5b10d96.pth",
"regnetx_800mf": "https://download.openmmlab.com/pretrain/third_party/regnetx_800mf-1f4be4c7.pth",
"regnetx_1.6gf": "https://download.openmmlab.com/pretrain/third_party/regnetx_1.6gf-5791c176.pth",
@@ -46,5 +46,5 @@
"resnest101": "https://download.openmmlab.com/pretrain/third_party/resnest101_d2-f3b931b2.pth",
"resnest200": "https://download.openmmlab.com/pretrain/third_party/resnest200_d2-ca88e41f.pth",
"darknet53": "https://download.openmmlab.com/pretrain/third_party/darknet53-a628ea1b.pth",
- "dbnet_det/mobilenet_v2": "https://download.openmmlab.com/dbnet_detection/v2.0/third_party/mobilenet_v2_batch256_imagenet-ff34753d.pth"
+ "mmdet/mobilenet_v2": "https://download.openmmlab.com/mmdetection/v2.0/third_party/mobilenet_v2_batch256_imagenet-ff34753d.pth"
}
diff --git a/cv/ocr/dbnet/pytorch/dbnet_cv/ops/csrc/common/cuda/deform_conv_cuda_kernel.cuh b/cv/ocr/dbnet/pytorch/dbnet_cv/ops/csrc/common/cuda/deform_conv_cuda_kernel.cuh
index 9e864bb8bada51caf485a3d06b8fe13c9e5dda34..fa58ffdc3d1537ac8c3fc5588be64448b4bf2a3f 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_cv/ops/csrc/common/cuda/deform_conv_cuda_kernel.cuh
+++ b/cv/ocr/dbnet/pytorch/dbnet_cv/ops/csrc/common/cuda/deform_conv_cuda_kernel.cuh
@@ -1,3 +1,5 @@
+/* Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. */
+/* All Rights Reserved. */
/*!
******************* BEGIN Caffe Copyright Notice and Disclaimer
*****************
@@ -61,7 +63,7 @@
*/
// modified from
-// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/dbnet_detection/dbnet_det/ops/dcn/src/deform_conv_cuda_kernel.cu
+// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu
#ifndef DEFORM_CONV_CUDA_KERNEL_CUH
#define DEFORM_CONV_CUDA_KERNEL_CUH
diff --git a/cv/ocr/dbnet/pytorch/dbnet_cv/ops/csrc/common/cuda/modulated_deform_conv_cuda_kernel.cuh b/cv/ocr/dbnet/pytorch/dbnet_cv/ops/csrc/common/cuda/modulated_deform_conv_cuda_kernel.cuh
index 5046c8d4f9496f790a7768ccdd9558026877ac54..d11e2b8b2ffc8d27d3f6a70ab248151180265211 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_cv/ops/csrc/common/cuda/modulated_deform_conv_cuda_kernel.cuh
+++ b/cv/ocr/dbnet/pytorch/dbnet_cv/ops/csrc/common/cuda/modulated_deform_conv_cuda_kernel.cuh
@@ -1,3 +1,5 @@
+/* Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. */
+/* All Rights Reserved. */
/*!
******************* BEGIN Caffe Copyright Notice and Disclaimer
*****************
@@ -61,7 +63,7 @@
*/
// modified from
-// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/dbnet_detection/dbnet_det/ops/dcn/src/deform_conv_cuda_kernel.cu
+// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu
#ifndef MODULATED_DEFORM_CONV_CUDA_KERNEL_CUH
#define MODULATED_DEFORM_CONV_CUDA_KERNEL_CUH
diff --git a/cv/ocr/dbnet/pytorch/dbnet_cv/ops/roi_align.py b/cv/ocr/dbnet/pytorch/dbnet_cv/ops/roi_align.py
index 7f094230d8e05c2f3209ae4a89c1b5187c948556..a4c1223897d629ee9394139cc84de066ca450ffb 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_cv/ops/roi_align.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_cv/ops/roi_align.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
@@ -141,7 +143,7 @@ class RoIAlign(nn.Module):
output sample. 0 to take samples densely for current models.
pool_mode (str, 'avg' or 'max'): pooling mode in each bin.
aligned (bool): if False, use the legacy implementation in
- dbnet_detection. If True, align the results more perfectly.
+ MMDetection. If True, align the results more perfectly.
use_torchvision (bool): whether to use roi_align from torchvision.
Note:
diff --git a/cv/ocr/dbnet/pytorch/dbnet_cv/runner/hooks/evaluation.py b/cv/ocr/dbnet/pytorch/dbnet_cv/runner/hooks/evaluation.py
index 3e73c32e3eebcb643763deabfcfbe8044a9d3842..e034a554fca0378047afd49184fd8fc54bb43f64 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_cv/runner/hooks/evaluation.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_cv/runner/hooks/evaluation.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import warnings
@@ -371,7 +373,7 @@ class EvalHook(Hook):
# If the performance of model is pool, the `eval_res` may be an
# empty dict and it will raise exception when `self.save_best` is
# not None. More details at
- # https://github.com/open-mmlab/dbnet_detection/issues/6265.
+ # https://github.com/open-mmlab/mmdetection/issues/6265.
if not eval_res:
warnings.warn(
'Since `eval_res` is an empty dict, the behavior to save '
diff --git a/cv/ocr/dbnet/pytorch/dbnet_cv/utils/registry.py b/cv/ocr/dbnet/pytorch/dbnet_cv/utils/registry.py
index a283583da4b9d336309665618868ca010e5bb18f..3a55ff39e0aa969c936c93301c64d6db930bc07a 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_cv/utils/registry.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_cv/utils/registry.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import inspect
import warnings
@@ -104,7 +106,7 @@ class Registry:
children registry could be built from parent. Default: None.
scope (str, optional): The scope of registry. It is the key to search
for children registry. If not specified, scope will be the name of
- the package where class is defined, e.g. dbnet_det, mmcls, mmseg.
+ the package where class is defined, e.g. mmdet, mmcls, mmseg.
Default: None.
"""
@@ -151,12 +153,12 @@ class Registry:
The name of the package where registry is defined will be returned.
Example:
- >>> # in dbnet_det/models/backbone/resnet.py
+ >>> # in mmdet/models/backbone/resnet.py
>>> MODELS = Registry('models')
>>> @MODELS.register_module()
>>> class ResNet:
>>> pass
- The scope of ``ResNet`` will be ``dbnet_det``.
+ The scope of ``ResNet`` will be ``mmdet``.
Returns:
str: The inferred scope name.
@@ -177,8 +179,8 @@ class Registry:
The first scope will be split from key.
Examples:
- >>> Registry.split_scope_key('dbnet_det.ResNet')
- 'dbnet_det', 'ResNet'
+ >>> Registry.split_scope_key('mmdet.ResNet')
+ 'mmdet', 'ResNet'
>>> Registry.split_scope_key('ResNet')
None, 'ResNet'
@@ -244,11 +246,11 @@ class Registry:
Example:
>>> models = Registry('models')
- >>> dbnet_det_models = Registry('models', parent=models)
- >>> @dbnet_det_models.register_module()
+ >>> mmdet_models = Registry('models', parent=models)
+ >>> @mmdet_models.register_module()
>>> class ResNet:
>>> pass
- >>> resnet = models.build(dict(type='dbnet_det.ResNet'))
+ >>> resnet = models.build(dict(type='mmdet.ResNet'))
"""
assert isinstance(registry, Registry)
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/bbox_overlaps.py b/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/bbox_overlaps.py
index d83eece76d0d4f05c4a94e73ab3b6e7e0488a884..2d1102ac11ec624260e1ec325d5b0638d23a1ca4 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/bbox_overlaps.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/bbox_overlaps.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
@@ -15,7 +17,7 @@ def bbox_overlaps(bboxes1,
mode (str): IOU (intersection over union) or IOF (intersection
over foreground)
use_legacy_coordinate (bool): Whether to use coordinate system in
- dbnet_det v1.x. which means width, height should be
+ mmdet v1.x. which means width, height should be
calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively.
Note when function is used in `VOCDataset`, it should be
True to align with the official implementation
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/eval_hooks.py b/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/eval_hooks.py
index 5ba682d74d18253bfcf1ca6a62f53ec7c4b6fd40..5cf56f999b7ae56a535f98454c74d6f14b0d51d6 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/eval_hooks.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/eval_hooks.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import bisect
import os.path as osp
@@ -55,7 +57,7 @@ class EvalHook(BaseEvalHook):
from dbnet_det.apis import single_gpu_test
- # Changed results to self.results so that dbnet_detWandbHook can access
+ # Changed results to self.results so that MMDetWandbHook can access
# the evaluation results and log them to wandb.
results = single_gpu_test(runner.model, self.dataloader, show=False)
self.latest_results = results
@@ -121,7 +123,7 @@ class DistEvalHook(BaseDistEvalHook):
from dbnet_det.apis import multi_gpu_test
- # Changed results to self.results so that dbnet_detWandbHook can access
+ # Changed results to self.results so that MMDetWandbHook can access
# the evaluation results and log them to wandb.
results = multi_gpu_test(
runner.model,
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/mean_ap.py b/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/mean_ap.py
index 3a2216da6c24c46f44a3579cb0e2b06d85c12201..9b9c55a2ef3b115d0ce4e86e8b80f761d6f0ded3 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/mean_ap.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/mean_ap.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from multiprocessing import Pool
@@ -77,7 +79,7 @@ def tpfp_imagenet(det_bboxes,
area_ranges (list[tuple] | None): Range of bbox areas to be evaluated,
in the format [(min1, max1), (min2, max2), ...]. Default: None.
use_legacy_coordinate (bool): Whether to use coordinate system in
- dbnet_det v1.x. which means width, height should be
+ mmdet v1.x. which means width, height should be
calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively.
Default: False.
@@ -186,7 +188,7 @@ def tpfp_default(det_bboxes,
evaluated, in the format [(min1, max1), (min2, max2), ...].
Default: None.
use_legacy_coordinate (bool): Whether to use coordinate system in
- dbnet_det v1.x. which means width, height should be
+ mmdet v1.x. which means width, height should be
calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively.
Default: False.
@@ -292,7 +294,7 @@ def tpfp_openimages(det_bboxes,
evaluated, in the format [(min1, max1), (min2, max2), ...].
Default: None.
use_legacy_coordinate (bool): Whether to use coordinate system in
- dbnet_det v1.x. which means width, height should be
+ mmdet v1.x. which means width, height should be
calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively.
Default: False.
gt_bboxes_group_of (ndarray): GT group_of of this image, of shape
@@ -567,7 +569,7 @@ def eval_map(det_results,
nproc (int): Processes used for computing TP and FP.
Default: 4.
use_legacy_coordinate (bool): Whether to use coordinate system in
- dbnet_det v1.x. which means width, height should be
+ mmdet v1.x. which means width, height should be
calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively.
Default: False.
use_group_of (bool): Whether to use group of when calculate TP and FP,
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/recall.py b/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/recall.py
index 4b41c4ae6f82ac4a65996bc9b46b0b34a7fabc79..25b1ca1dc7717d54e97729cab084198daf33dd15 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/recall.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/core/evaluation/recall.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from collections.abc import Sequence
@@ -78,7 +80,7 @@ def eval_recalls(gts,
logger (logging.Logger | str | None): The way to print the recall
summary. See `dbnet_cv.utils.print_log()` for details. Default: None.
use_legacy_coordinate (bool): Whether use coordinate system
- in dbnet_det v1.x. "1" was added to both height and width
+ in mmdet v1.x. "1" was added to both height and width
which means w, h should be
computed as 'x2 - x1 + 1` and 'y2 - y1 + 1'. Default: False.
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/datasets/pipelines/loading.py b/cv/ocr/dbnet/pytorch/dbnet_det/datasets/pipelines/loading.py
index 1c29642ecb2ea8de735df35169961fb60d306906..391b328498b7b03a0b03cffe8f308571d1bde076 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/datasets/pipelines/loading.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/datasets/pipelines/loading.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
@@ -49,7 +51,7 @@ class LoadImageFromFile:
"""Call functions to load image and get image meta information.
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded image and meta information.
@@ -154,7 +156,7 @@ class LoadMultiChannelImageFromFiles:
information.
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded images and meta information.
@@ -246,7 +248,7 @@ class LoadAnnotations:
"""Private function to load bounding box annotations.
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded bounding box annotations.
@@ -278,7 +280,7 @@ class LoadAnnotations:
"""Private function to load label annotations.
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded label annotations.
@@ -335,7 +337,7 @@ class LoadAnnotations:
"""Private function to load mask annotations.
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded mask annotations.
@@ -381,7 +383,7 @@ class LoadAnnotations:
"""Call function to load multiple types annotations.
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded bounding box, label, mask and
@@ -458,7 +460,7 @@ class LoadPanopticAnnotations(LoadAnnotations):
`num_things + num_stuff - 1`, 255 means the ignored label (`VOID`).
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded mask and semantic segmentation
@@ -501,7 +503,7 @@ class LoadPanopticAnnotations(LoadAnnotations):
"""Call function to load multiple types panoptic annotations.
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded bounding box, label, mask and
@@ -540,7 +542,7 @@ class LoadProposals:
"""Call function to load proposals from file.
Args:
- results (dict): Result dict from :obj:`dbnet_det.CustomDataset`.
+ results (dict): Result dict from :obj:`mmdet.CustomDataset`.
Returns:
dict: The dict contains loaded proposal annotations.
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/datasets/samplers/class_aware_sampler.py b/cv/ocr/dbnet/pytorch/dbnet_det/datasets/samplers/class_aware_sampler.py
index 91ee88d75c994b0029ed0c8ca7fde40af5a949cd..f6a17cdbf8df814d1833d048fe775f4b0232a384 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/datasets/samplers/class_aware_sampler.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/datasets/samplers/class_aware_sampler.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import math
@@ -18,7 +20,7 @@ class ClassAwareSampler(Sampler):
Neural Networks `_
The implementation logic is referred to
- https://github.com/Sense-X/TSD/blob/master/dbnet_det/datasets/samplers/distributed_classaware_sampler.py
+ https://github.com/Sense-X/TSD/blob/master/mmdet/datasets/samplers/distributed_classaware_sampler.py
Args:
dataset: Dataset used for sampling.
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/models/__init__.py b/cv/ocr/dbnet/pytorch/dbnet_det/models/__init__.py
index d16681ec98ce6ae278547784b8b1a0b70431eeda..65006afdcc573261c06d3f84a60e02f90564db49 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/models/__init__.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/models/__init__.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from .backbones import * # noqa: F401,F403
from .builder import (BACKBONES, DETECTORS, HEADS, LOSSES, NECKS,
@@ -12,8 +14,8 @@ from .detectors import * # noqa: F401,F403
# from .roi_heads import * # noqa: F401,F403
# from .seg_heads import * # noqa: F401,F403
-__all__ = [
- 'BACKBONES', 'NECKS', 'ROI_EXTRACTORS', 'SHARED_HEADS', 'HEADS', 'LOSSES',
- 'DETECTORS', 'build_backbone', 'build_neck', 'build_roi_extractor',
- 'build_shared_head', 'build_head', 'build_loss', 'build_detector'
-]
+# __all__ = [
+# 'BACKBONES', 'NECKS', 'ROI_EXTRACTORS', 'SHARED_HEADS', 'HEADS', 'LOSSES',
+# 'DETECTORS', 'build_backbone', 'build_neck', 'build_roi_extractor',
+# 'build_shared_head', 'build_head', 'build_loss', 'build_detector'
+# ]
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/models/backbones/__init__.py b/cv/ocr/dbnet/pytorch/dbnet_det/models/backbones/__init__.py
index bb083fc70a19a1e0c400cee7a2c4fd1bfbf20103..866f54e177d777eca2d29daf0e187fa7632c6e1d 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/models/backbones/__init__.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/models/backbones/__init__.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
# from .csp_darknet import CSPDarknet
# from .darknet import Darknet
@@ -6,7 +8,7 @@
# from .efficientnet import EfficientNet
# from .hourglass import HourglassNet
# from .hrnet import HRNet
-from .mobilenet_v3 import MobileNetV3
+# from .mobilenet_v2 import MobileNetV2
# from .pvt import PyramidVisionTransformer, PyramidVisionTransformerV2
# from .regnet import RegNet
# from .res2net import Res2Net
@@ -24,7 +26,3 @@ from .resnet import ResNet, ResNetV1d
# 'SwinTransformer', 'PyramidVisionTransformer',
# 'PyramidVisionTransformerV2', 'EfficientNet'
# ]
-__all__ = [
- 'ResNet',
- 'MobileNetV3'
-]
\ No newline at end of file
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/models/detectors/base.py b/cv/ocr/dbnet/pytorch/dbnet_det/models/detectors/base.py
index fa74c58e2d13657d6b83c4a01a7baa7eeaa27a38..35a02dbc74bfb224b505a7da55a152e188e76274 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/models/detectors/base.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/models/detectors/base.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from abc import ABCMeta, abstractmethod
from collections import OrderedDict
@@ -69,7 +71,7 @@ class BaseDetector(BaseModule, metaclass=ABCMeta):
has: 'img_shape', 'scale_factor', 'flip', and may also contain
'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.
For details on the values of these keys, see
- :class:`dbnet_det.datasets.pipelines.Collect`.
+ :class:`mmdet.datasets.pipelines.Collect`.
kwargs (keyword arguments): Specific to concrete implementation.
"""
# NOTE the batched image size information may be useful, e.g.
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/models/detectors/single_stage.py b/cv/ocr/dbnet/pytorch/dbnet_det/models/detectors/single_stage.py
index ac9cfd78da70d8ab2efa0ca442dd6ebf356cbf32..1b6b2d391edd830e7a136057a2103ba622f43ad4 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/models/detectors/single_stage.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/models/detectors/single_stage.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import warnings
@@ -48,7 +50,7 @@ class SingleStageDetector(BaseDetector):
def forward_dummy(self, img):
"""Used for computing network flops.
- See `dbnet_detection/tools/analysis_tools/get_flops.py`
+ See `mmdetection/tools/analysis_tools/get_flops.py`
"""
x = self.extract_feat(img)
outs = self.bbox_head(x)
@@ -68,7 +70,7 @@ class SingleStageDetector(BaseDetector):
has: 'img_shape', 'scale_factor', 'flip', and may also contain
'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.
For details on the values of these keys see
- :class:`dbnet_det.datasets.pipelines.Collect`.
+ :class:`mmdet.datasets.pipelines.Collect`.
gt_bboxes (list[Tensor]): Each item are the truth boxes for each
image in [tl_x, tl_y, br_x, br_y] format.
gt_labels (list[Tensor]): Class indices corresponding to each box
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/models/utils/__init__.py b/cv/ocr/dbnet/pytorch/dbnet_det/models/utils/__init__.py
index d154cdeea22b5d18d8fa1d44409bd38910c60850..848e7eabc3bcaddc73949814cf61c61a07ed98d0 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/models/utils/__init__.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/models/utils/__init__.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
# from .brick_wrappers import AdaptiveAvgPool2d, adaptive_avg_pool2d
# from .builder import build_linear_layer, build_transformer
@@ -5,8 +7,8 @@
# from .conv_upsample import ConvUpsample
# from .csp_layer import CSPLayer
# from .gaussian_target import gaussian_radius, gen_gaussian_target
-from .inverted_residual import InvertedResidual
-from .make_divisible import make_divisible
+# from .inverted_residual import InvertedResidual
+# from .make_divisible import make_divisible
# from .misc import interpolate_as, sigmoid_geometric_mean
# from .normed_predictor import NormedConv2d, NormedLinear
# from .panoptic_gt_processing import preprocess_panoptic_gt
@@ -15,7 +17,7 @@ from .make_divisible import make_divisible
# from .positional_encoding import (LearnedPositionalEncoding,
# SinePositionalEncoding)
from .res_layer import ResLayer, SimplifiedBasicBlock
-from .se_layer import SELayer
+# from .se_layer import DyReLU, SELayer
# from .transformer import (DetrTransformerDecoder, DetrTransformerDecoderLayer,
# DynamicConv, PatchEmbed, Transformer, nchw_to_nlc,
# nlc_to_nchw)
diff --git a/cv/ocr/dbnet/pytorch/dbnet_det/utils/logger.py b/cv/ocr/dbnet/pytorch/dbnet_det/utils/logger.py
index 29f57e7cf27d5dd9d49f4d841fb8df6a1b26997a..d9736e7003d26c9114c7ee1feb2336bba92bb06d 100755
--- a/cv/ocr/dbnet/pytorch/dbnet_det/utils/logger.py
+++ b/cv/ocr/dbnet/pytorch/dbnet_det/utils/logger.py
@@ -1,3 +1,5 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import inspect
import logging
@@ -16,7 +18,7 @@ def get_root_logger(log_file=None, log_level=logging.INFO):
Returns:
:obj:`logging.Logger`: The obtained logger
"""
- logger = get_logger(name='dbnet_det', log_file=log_file, log_level=log_level)
+ logger = get_logger(name='mmdet', log_file=log_file, log_level=log_level)
return logger
diff --git a/cv/ocr/dbnet/pytorch/requirements.txt b/cv/ocr/dbnet/pytorch/requirements.txt
index 9b52871dcd3c2665f06c8f008b5c39c2c4607457..6981bd723391a980c0f22baeab39d0adbcb68679 100755
--- a/cv/ocr/dbnet/pytorch/requirements.txt
+++ b/cv/ocr/dbnet/pytorch/requirements.txt
@@ -1,12 +1,4 @@
-
-
-addict
-yapf
-terminaltables
-pycocotools
-lmdb
-shapely
-pyclipper
-imgaug
-
-
+-r requirements/build.txt
+-r requirements/optional.txt
+-r requirements/runtime.txt
+-r requirements/tests.txt
diff --git a/cv/ocr/dbnet/pytorch/requirements/albu.txt b/cv/ocr/dbnet/pytorch/requirements/albu.txt
new file mode 100755
index 0000000000000000000000000000000000000000..ddcc3fb3b271dcad3526ef130e1267be3fc20b5b
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/requirements/albu.txt
@@ -0,0 +1 @@
+albumentations>=1.1.0 --no-binary qudida,albumentations
diff --git a/cv/ocr/dbnet/pytorch/requirements/build.txt b/cv/ocr/dbnet/pytorch/requirements/build.txt
new file mode 100755
index 0000000000000000000000000000000000000000..e06b090722e0079badeb07d094d39571754995e4
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/requirements/build.txt
@@ -0,0 +1,4 @@
+# These must be installed before building mmocr
+numpy
+pyclipper
+torch>=1.1
diff --git a/cv/ocr/dbnet/pytorch/requirements/docs.txt b/cv/ocr/dbnet/pytorch/requirements/docs.txt
new file mode 100755
index 0000000000000000000000000000000000000000..3d648e22c39299041a605be2b3eb5de9bae0eacb
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/requirements/docs.txt
@@ -0,0 +1,7 @@
+docutils==0.16.0
+markdown>=3.4.0
+myst-parser
+-e git+https://github.com/open-mmlab/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
+sphinx==4.0.2
+sphinx_copybutton
+sphinx_markdown_tables>=0.0.16
diff --git a/cv/ocr/dbnet/pytorch/requirements/mminstall.txt b/cv/ocr/dbnet/pytorch/requirements/mminstall.txt
new file mode 100755
index 0000000000000000000000000000000000000000..047a07f790870b51a331c49d64f1fe7bc27674f4
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/requirements/mminstall.txt
@@ -0,0 +1,2 @@
+dbnet_cv-full>=1.3.8
+mmdet>=2.21.0
diff --git a/cv/ocr/dbnet/pytorch/requirements/optional.txt b/cv/ocr/dbnet/pytorch/requirements/optional.txt
new file mode 100755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/cv/ocr/dbnet/pytorch/requirements/readthedocs.txt b/cv/ocr/dbnet/pytorch/requirements/readthedocs.txt
new file mode 100755
index 0000000000000000000000000000000000000000..3673aa5cec24345d7d6c767f8212f37eabd21ec6
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/requirements/readthedocs.txt
@@ -0,0 +1,16 @@
+imgaug
+kwarray
+lanms-neo==1.0.2
+lmdb
+matplotlib
+dbnet_cv
+mmdet
+pyclipper
+rapidfuzz>=2.0.0
+regex
+scikit-image
+scipy
+shapely
+titlecase
+torch
+torchvision
diff --git a/cv/ocr/dbnet/pytorch/requirements/runtime.txt b/cv/ocr/dbnet/pytorch/requirements/runtime.txt
new file mode 100755
index 0000000000000000000000000000000000000000..02df3dcf5e9109eedbaa82ef5d97772653134143
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/requirements/runtime.txt
@@ -0,0 +1,10 @@
+imgaug
+lanms-neo==1.0.2
+lmdb
+matplotlib
+numpy
+opencv-python >=4.2.0.32, != 4.5.5.* # avoid Github security alert
+pyclipper
+pycocotools
+rapidfuzz>=2.0.0
+scikit-image
diff --git a/cv/ocr/dbnet/pytorch/requirements/tests.txt b/cv/ocr/dbnet/pytorch/requirements/tests.txt
new file mode 100755
index 0000000000000000000000000000000000000000..1a613e2b0c9ed9c1326be2a699d0b5353ed073be
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/requirements/tests.txt
@@ -0,0 +1,12 @@
+asynctest
+codecov
+flake8
+isort
+# Note: used for kwarray.group_items, this may be ported to dbnet_cv in the future.
+kwarray
+pytest
+pytest-cov
+pytest-runner
+ubelt
+xdoctest >= 0.10.0
+yapf
diff --git a/cv/ocr/dbnet/pytorch/run2.sh b/cv/ocr/dbnet/pytorch/run2.sh
new file mode 100755
index 0000000000000000000000000000000000000000..fc95fed79febdd5bcd5a202442b1e538a3a88b0a
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/run2.sh
@@ -0,0 +1,2 @@
+export PYTHONPATH=$PYTHONPATH:/home/yongle.wu2/learning_tutorial/yongle.wu/DBnet/mmocr
+CUDA_VISIBLE_DEVICES=3 python3 tools/train.py configs/textdet/dbnet/dbnet_r18_fpnc_1200e_icdar2015.py
diff --git a/cv/ocr/dbnet/pytorch/run3.sh b/cv/ocr/dbnet/pytorch/run3.sh
new file mode 100755
index 0000000000000000000000000000000000000000..628dee7f5cf2c05ee39bfec593211bd12097495d
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/run3.sh
@@ -0,0 +1,2 @@
+
+CUDA_VIiSIBLE_DEVICES=3 python3 tools/train.py configs/textdet/dbnet/dbnet_r50dcnv2_fpnc_1200e_icdar2015.py
diff --git a/cv/ocr/dbnet/pytorch/tools/analyze_logs.py b/cv/ocr/dbnet/pytorch/tools/analyze_logs.py
index 349735ef1894c7a6ad74b794104908def734a003..5ad1b7645ced1defc48730d7347aaad6de4efcae 100755
--- a/cv/ocr/dbnet/pytorch/tools/analyze_logs.py
+++ b/cv/ocr/dbnet/pytorch/tools/analyze_logs.py
@@ -1,6 +1,8 @@
+# Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
+# All Rights Reserved.
# Copyright (c) OpenMMLab. All rights reserved.
"""Modified from https://github.com/open-
-mmlab/dbnet_detection/blob/master/tools/analysis_tools/analyze_logs.py."""
+mmlab/mmdetection/blob/master/tools/analysis_tools/analyze_logs.py."""
import argparse
import json
from collections import defaultdict
diff --git a/cv/ocr/dbnet/pytorch/tools/dist_train.sh b/cv/ocr/dbnet/pytorch/tools/dist_train.sh
new file mode 100755
index 0000000000000000000000000000000000000000..b939dd9365a75f47b03c2b5bd51428796de5dcf5
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/tools/dist_train.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+if [ $# -lt 3 ]
+then
+ echo "Usage: bash $0 CONFIG WORK_DIR GPUS"
+ exit
+fi
+
+CONFIG=$1
+WORK_DIR=$2
+GPUS=$3
+NNODES=${NNODES:-1}
+NODE_RANK=${NODE_RANK:-0}
+PORT=${PORT:-29500}
+MASTER_ADDR=${MASTER_ADDR:-"127.0.0.1"}
+
+PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \
+
+if [ ${GPUS} == 1 ]; then
+ python $(dirname "$0")/train.py $CONFIG --work-dir=${WORK_DIR} ${@:4}
+else
+ python -m torch.distributed.launch \
+ --nnodes=$NNODES \
+ --node_rank=$NODE_RANK \
+ --master_addr=$MASTER_ADDR \
+ --nproc_per_node=$GPUS \
+ --master_port=$PORT \
+ $(dirname "$0")/train.py \
+ $CONFIG \
+ --seed 0 \
+ --work-dir=${WORK_DIR} \
+ --launcher pytorch ${@:4}
+fi
diff --git a/cv/ocr/dbnet/pytorch/tools/train.py b/cv/ocr/dbnet/pytorch/tools/train.py
new file mode 100755
index 0000000000000000000000000000000000000000..bea2b037e2516efaf4412d18baf2ca8e552c51c2
--- /dev/null
+++ b/cv/ocr/dbnet/pytorch/tools/train.py
@@ -0,0 +1,230 @@
+#!/usr/bin/env python
+# Copyright (c) OpenMMLab. All rights reserved.
+import argparse
+import copy
+import os
+import os.path as osp
+import time
+import warnings
+
+import dbnet_cv
+import torch
+import torch.distributed as dist
+from dbnet_cv import Config, DictAction
+from dbnet_cv.runner import get_dist_info, init_dist, set_random_seed
+from dbnet_cv.utils import get_git_hash
+
+from dbnet import __version__
+from dbnet.apis import init_random_seed, train_detector
+from dbnet.datasets import build_dataset
+from dbnet.models import build_detector
+from dbnet.utils import (collect_env, get_root_logger, is_2dlist,
+ setup_multi_processes)
+
+
+def parse_args():
+ parser = argparse.ArgumentParser(description='Train a detector.')
+ parser.add_argument('config', help='Train config file path.')
+ parser.add_argument('--work-dir', help='The dir to save logs and models.')
+ parser.add_argument(
+ '--load-from', help='The checkpoint file to load from.')
+ parser.add_argument(
+ '--resume-from', help='The checkpoint file to resume from.')
+ parser.add_argument(
+ '--no-validate',
+ action='store_true',
+ help='Whether not to evaluate the checkpoint during training.')
+ group_gpus = parser.add_mutually_exclusive_group()
+ group_gpus.add_argument(
+ '--gpus',
+ type=int,
+ help='(Deprecated, please use --gpu-id) number of gpus to use '
+ '(only applicable to non-distributed training).')
+ group_gpus.add_argument(
+ '--gpu-ids',
+ type=int,
+ nargs='+',
+ help='(Deprecated, please use --gpu-id) ids of gpus to use '
+ '(only applicable to non-distributed training)')
+ group_gpus.add_argument(
+ '--gpu-id',
+ type=int,
+ default=0,
+ help='id of gpu to use '
+ '(only applicable to non-distributed training)')
+ parser.add_argument('--seed', type=int, default=None, help='Random seed.')
+ parser.add_argument(
+ '--diff-seed',
+ action='store_true',
+ help='Whether or not set different seeds for different ranks')
+ parser.add_argument(
+ '--deterministic',
+ action='store_true',
+ help='Whether to set deterministic options for CUDNN backend.')
+ parser.add_argument(
+ '--options',
+ nargs='+',
+ action=DictAction,
+ help='Override some settings in the used config, the key-value pair '
+ 'in xxx=yyy format will be merged into config file (deprecate), '
+ 'change to --cfg-options instead.')
+ parser.add_argument(
+ '--cfg-options',
+ nargs='+',
+ action=DictAction,
+ help='Override some settings in the used config, the key-value pair '
+ 'in xxx=yyy format will be merged into config file. If the value to '
+ 'be overwritten is a list, it should be of the form of either '
+ 'key="[a,b]" or key=a,b .The argument also allows nested list/tuple '
+ 'values, e.g. key="[(a,b),(c,d)]". Note that the quotation marks '
+ 'are necessary and that no white space is allowed.')
+ parser.add_argument(
+ '--launcher',
+ choices=['none', 'pytorch', 'slurm', 'mpi'],
+ default='none',
+ help='Options for job launcher.')
+ parser.add_argument('--local_rank', '--local-rank', type=int, default=0)
+
+ args = parser.parse_args()
+ if 'LOCAL_RANK' not in os.environ:
+ os.environ['LOCAL_RANK'] = str(args.local_rank)
+
+ if args.options and args.cfg_options:
+ raise ValueError(
+ '--options and --cfg-options cannot be both '
+ 'specified, --options is deprecated in favor of --cfg-options')
+ if args.options:
+ warnings.warn('--options is deprecated in favor of --cfg-options')
+ args.cfg_options = args.options
+
+ return args
+
+
+def main():
+ args = parse_args()
+
+ cfg = Config.fromfile(args.config)
+ if args.cfg_options is not None:
+ cfg.merge_from_dict(args.cfg_options)
+
+ setup_multi_processes(cfg)
+
+ # set cudnn_benchmark
+ if cfg.get('cudnn_benchmark', False):
+ torch.backends.cudnn.benchmark = True
+
+ # work_dir is determined in this priority: CLI > segment in file > filename
+ if args.work_dir is not None:
+ # update configs according to CLI args if args.work_dir is not None
+ cfg.work_dir = args.work_dir
+ elif cfg.get('work_dir', None) is None:
+ # use config filename as default work_dir if cfg.work_dir is None
+ cfg.work_dir = osp.join('./work_dirs',
+ osp.splitext(osp.basename(args.config))[0])
+ if args.load_from is not None:
+ cfg.load_from = args.load_from
+ if args.resume_from is not None:
+ cfg.resume_from = args.resume_from
+ if args.gpus is not None:
+ cfg.gpu_ids = range(1)
+ warnings.warn('`--gpus` is deprecated because we only support '
+ 'single GPU mode in non-distributed training. '
+ 'Use `gpus=1` now.')
+ if args.gpu_ids is not None:
+ cfg.gpu_ids = args.gpu_ids[0:1]
+ warnings.warn('`--gpu-ids` is deprecated, please use `--gpu-id`. '
+ 'Because we only support single GPU mode in '
+ 'non-distributed training. Use the first GPU '
+ 'in `gpu_ids` now.')
+ if args.gpus is None and args.gpu_ids is None:
+ cfg.gpu_ids = [args.gpu_id]
+
+ # init distributed env first, since logger depends on the dist info.
+ if args.launcher == 'none':
+ distributed = False
+ else:
+ distributed = True
+ init_dist(args.launcher, **cfg.dist_params)
+ # re-set gpu_ids with distributed training mode
+ _, world_size = get_dist_info()
+ cfg.gpu_ids = range(world_size)
+
+ # create work_dir
+ dbnet_cv.mkdir_or_exist(osp.abspath(cfg.work_dir))
+ # dump config
+ cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config)))
+ # init the logger before other steps
+ timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime())
+ log_file = osp.join(cfg.work_dir, f'{timestamp}.log')
+ logger = get_root_logger(log_file=log_file, log_level=cfg.log_level)
+
+ # init the meta dict to record some important information such as
+ # environment info and seed, which will be logged
+ meta = dict()
+ # log env info
+ env_info_dict = collect_env()
+ env_info = '\n'.join([(f'{k}: {v}') for k, v in env_info_dict.items()])
+ dash_line = '-' * 60 + '\n'
+ logger.info('Environment info:\n' + dash_line + env_info + '\n' +
+ dash_line)
+ meta['env_info'] = env_info
+ meta['config'] = cfg.pretty_text
+ # log some basic info
+ logger.info(f'Distributed training: {distributed}')
+ logger.info(f'Config:\n{cfg.pretty_text}')
+
+ # set random seeds
+ seed = init_random_seed(args.seed)
+ seed = seed + dist.get_rank() if args.diff_seed else seed
+ logger.info(f'Set random seed to {seed}, '
+ f'deterministic: {args.deterministic}')
+ set_random_seed(seed, deterministic=args.deterministic)
+ cfg.seed = seed
+ meta['seed'] = seed
+ meta['exp_name'] = osp.basename(args.config)
+
+ model = build_detector(
+ cfg.model,
+ train_cfg=cfg.get('train_cfg'),
+ test_cfg=cfg.get('test_cfg'))
+ model.init_weights()
+
+ datasets = [build_dataset(cfg.data.train)]
+ if len(cfg.workflow) == 2:
+ val_dataset = copy.deepcopy(cfg.data.val)
+ if cfg.data.train.get('pipeline', None) is None:
+ if is_2dlist(cfg.data.train.datasets):
+ train_pipeline = cfg.data.train.datasets[0][0].pipeline
+ else:
+ train_pipeline = cfg.data.train.datasets[0].pipeline
+ elif is_2dlist(cfg.data.train.pipeline):
+ train_pipeline = cfg.data.train.pipeline[0]
+ else:
+ train_pipeline = cfg.data.train.pipeline
+
+ if val_dataset['type'] in ['ConcatDataset', 'UniformConcatDataset']:
+ for dataset in val_dataset['datasets']:
+ dataset.pipeline = train_pipeline
+ else:
+ val_dataset.pipeline = train_pipeline
+ datasets.append(build_dataset(val_dataset))
+ if cfg.get('checkpoint_config', None) is not None:
+ # save mmdet version, config file content and class names in
+ # checkpoints as meta data
+ cfg.checkpoint_config.meta = dict(
+ mmocr_version=__version__ + get_git_hash()[:7],
+ CLASSES=datasets[0].CLASSES)
+ # add an attribute for visualization convenience
+ model.CLASSES = datasets[0].CLASSES
+ train_detector(
+ model,
+ datasets,
+ cfg,
+ distributed=distributed,
+ validate=(not args.no_validate),
+ timestamp=timestamp,
+ meta=meta)
+
+
+if __name__ == '__main__':
+ main()