Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -5,17 +5,19 @@ tags:
|
|
| 5 |
- text-detection
|
| 6 |
- scene-text-detection
|
| 7 |
- mmocr
|
| 8 |
-
- monkeyocr
|
| 9 |
---
|
| 10 |
|
| 11 |
# MonkeyOCRv2 Detection
|
| 12 |
|
| 13 |
-
|
|
|
|
| 14 |
[MonkeyOCRv2-AS](https://huggingface.co/zenosai/MonkeyOCRv2-AS) (ViTAEv2-S,
|
| 15 |
-
21M parameters) into **DBNet** and **PSENet** scene text
|
| 16 |
-
[MMOCR](https://github.com/open-mmlab/mmocr). The four-stage
|
| 17 |
-
(strides 4/8/16/32) are exposed as `res2`–`res5` and fed to
|
| 18 |
-
FPNF necks, so no change to the detection heads is
|
|
|
|
| 19 |
|
| 20 |
Training and evaluation follow the official MMOCR protocols on Total-Text,
|
| 21 |
CTW1500, and ICDAR2015.
|
|
@@ -24,42 +26,41 @@ CTW1500, and ICDAR2015.
|
|
| 24 |
|
| 25 |
Replacing the ImageNet-pretrained ResNet-50 with the MonkeyOCRv2-AS encoder
|
| 26 |
consistently improves F-score over both the baseline and the
|
| 27 |
-
[oCLIP](https://github.com/
|
| 28 |
-
results reproduced by us with MMOCR.
|
| 29 |
|
| 30 |
### Total-Text
|
| 31 |
|
| 32 |
-
| Method
|
| 33 |
-
| --- | ---: | ---: | ---: |
|
| 34 |
-
| DBNet
|
| 35 |
-
| DBNet + oCLIP
|
| 36 |
| **DBNet + MonkeyOCRv2** | **87.7** | 80.1 | **83.7** |
|
| 37 |
|
| 38 |
### CTW1500
|
| 39 |
|
| 40 |
-
| Method
|
| 41 |
-
| --- | ---: | ---: | ---: |
|
| 42 |
-
| PSENet
|
| 43 |
-
| PSENet + oCLIP
|
| 44 |
| **PSENet + MonkeyOCRv2** | **88.3** | 82.0 | **85.1** |
|
| 45 |
|
| 46 |
### ICDAR2015
|
| 47 |
|
| 48 |
-
| Method
|
| 49 |
-
| --- | ---: | ---: | ---: |
|
| 50 |
-
| PSENet
|
| 51 |
-
| PSENet + oCLIP
|
| 52 |
-
| **PSENet + MonkeyOCRv2** | **90.4** |
|
| 53 |
-
| DBNet
|
| 54 |
-
| DBNet + oCLIP
|
| 55 |
-
| **DBNet + MonkeyOCRv2**
|
| 56 |
|
| 57 |
### Checkpoints
|
| 58 |
|
| 59 |
Download the checkpoints from
|
| 60 |
-
[HB16888/
|
| 61 |
(HuggingFace) or
|
| 62 |
-
[WangXinhan/
|
| 63 |
(ModelScope):
|
| 64 |
|
| 65 |
```bash
|
|
@@ -72,20 +73,20 @@ modelscope download --model WangXinhan/MonkeyOCRv2_det --local_dir ./model_weigh
|
|
| 72 |
Each checkpoint is the best epoch on the test set, i.e. exactly the row
|
| 73 |
reported in the tables above.
|
| 74 |
|
| 75 |
-
| Checkpoint
|
| 76 |
-
| --- | --- | --- | ---: | --- |
|
| 77 |
-
|
|
| 78 |
-
|
|
| 79 |
-
|
|
| 80 |
-
|
|
| 81 |
-
|
|
| 82 |
-
|
|
| 83 |
-
|
|
| 84 |
-
|
|
| 85 |
-
|
|
| 86 |
-
|
|
| 87 |
-
|
|
| 88 |
-
|
|
| 89 |
|
| 90 |
## Environment
|
| 91 |
|
|
@@ -102,25 +103,6 @@ This directory is an add-on on top of the official MMOCR v1.0.1. Run:
|
|
| 102 |
bash install.sh # clones MMOCR v1.0.1 into ./mmocr and patches it
|
| 103 |
```
|
| 104 |
|
| 105 |
-
The add-on contains:
|
| 106 |
-
|
| 107 |
-
- `mmocr/models/common/backbones/monkeyocr_v2_vitae.py` — MMEngine wrapper
|
| 108 |
-
that loads the HuggingFace MonkeyOCRv2-AS encoder (via `transformers`
|
| 109 |
-
`AutoModel`, `trust_remote_code=True`) and exposes its four stages as
|
| 110 |
-
`res2`–`res5`. Image normalization (ViTAE mean/std) and patch splitting are
|
| 111 |
-
performed inside the backbone; the data preprocessor must use
|
| 112 |
-
`mean=None`, `std=None`, `bgr_to_rgb=True`, `pad_size_divisor=32`.
|
| 113 |
-
- `mmocr/models/textdet/postprocessors/pse_postprocessor.py` — one-line fix
|
| 114 |
-
for the PSE kernel-growing condition (`or` → `and` when filtering by
|
| 115 |
-
`score_threshold`), which improves the PSENet postprocessing quality.
|
| 116 |
-
- `dataset_zoo/ctw1500/textdet.py` — updated MD5 sums and archive layouts
|
| 117 |
-
for the CTW1500 download sources (the official Box/CloudStor archives were
|
| 118 |
-
re-uploaded and no longer match the upstream checksums).
|
| 119 |
-
- `tools/test.py` — accepts `--out` when `test_evaluator` is a plain dict.
|
| 120 |
-
- `tools/dataset_converters/prepare_all_datasets.sh` — prepares ICDAR2015,
|
| 121 |
-
CTW1500, and Total-Text in one go.
|
| 122 |
-
- `configs/textdet/{dbnet,psenet}/` — the 12 training configs listed above.
|
| 123 |
-
|
| 124 |
## Pretrained Backbone
|
| 125 |
|
| 126 |
Download the MonkeyOCRv2-AS visual encoder before training or evaluation:
|
|
@@ -129,10 +111,6 @@ Download the MonkeyOCRv2-AS visual encoder before training or evaluation:
|
|
| 129 |
hf download zenosai/MonkeyOCRv2-AS --local-dir ./pretrained/monkeyocrv2_as
|
| 130 |
```
|
| 131 |
|
| 132 |
-
The configs reference `pretrained/monkeyocrv2_as` relative to the MMOCR
|
| 133 |
-
working directory. The weights are identical to the ones used to produce the
|
| 134 |
-
results above (verified by MD5).
|
| 135 |
-
|
| 136 |
## Datasets
|
| 137 |
|
| 138 |
```bash
|
|
@@ -196,15 +174,6 @@ bash tools/dist_train.sh configs/textdet/dbnet/dbnet_resnet50-oclip_1200e_icdar2
|
|
| 196 |
bash tools/dist_train.sh configs/textdet/dbnet/dbnet_mkv2vitae_1200e_icdar2015_2gpu_adamw.py 2
|
| 197 |
```
|
| 198 |
|
| 199 |
-
Notes:
|
| 200 |
-
|
| 201 |
-
- The oCLIP backbone weights (`resnet50-oclip-7ba0c533.pth`) are fetched
|
| 202 |
-
automatically from `download.openmmlab.com` via `init_cfg`.
|
| 203 |
-
- The MonkeyOCRv2 configs load the encoder from
|
| 204 |
-
`pretrained/monkeyocrv2_as` (see [Pretrained Backbone](#pretrained-backbone)).
|
| 205 |
-
- Every config sets `randomness = dict(seed=42)`; results are selected by the
|
| 206 |
-
best test-set hmean over the training run, evaluated every 20 epochs.
|
| 207 |
-
|
| 208 |
## Evaluation
|
| 209 |
|
| 210 |
```bash
|
|
@@ -225,6 +194,7 @@ The evaluation prints `precision / recall / hmean` with the
|
|
| 225 |
## Acknowledgements
|
| 226 |
|
| 227 |
This project builds on [MMOCR](https://github.com/open-mmlab/mmocr),
|
| 228 |
-
[DBNet](https://
|
| 229 |
-
[PSENet](https://
|
| 230 |
-
[oCLIP](https://
|
|
|
|
|
|
| 5 |
- text-detection
|
| 6 |
- scene-text-detection
|
| 7 |
- mmocr
|
| 8 |
+
- monkeyocr v2
|
| 9 |
---
|
| 10 |
|
| 11 |
# MonkeyOCRv2 Detection
|
| 12 |
|
| 13 |
+
This repository provides the text detection experiments from the
|
| 14 |
+
[MonkeyOCRv2 paper](https://arxiv.org/abs/2607.11562). The visual encoder from
|
| 15 |
[MonkeyOCRv2-AS](https://huggingface.co/zenosai/MonkeyOCRv2-AS) (ViTAEv2-S,
|
| 16 |
+
21M parameters) is integrated into **DBNet** and **PSENet** scene text
|
| 17 |
+
detectors via [MMOCR](https://github.com/open-mmlab/mmocr). The four-stage
|
| 18 |
+
ViTAEv2 features (strides 4/8/16/32) are exposed as `res2`–`res5` and fed to
|
| 19 |
+
the standard FPNC / FPNF necks, so no change to the detection heads is
|
| 20 |
+
required.
|
| 21 |
|
| 22 |
Training and evaluation follow the official MMOCR protocols on Total-Text,
|
| 23 |
CTW1500, and ICDAR2015.
|
|
|
|
| 26 |
|
| 27 |
Replacing the ImageNet-pretrained ResNet-50 with the MonkeyOCRv2-AS encoder
|
| 28 |
consistently improves F-score over both the baseline and the
|
| 29 |
+
[oCLIP](https://github.com/bytedance/oclip)-pretrained backbone.
|
|
|
|
| 30 |
|
| 31 |
### Total-Text
|
| 32 |
|
| 33 |
+
| Method | P | R | F |
|
| 34 |
+
| ----------------------- | -------: | ---: | -------: |
|
| 35 |
+
| DBNet (ResNet-50) | 82.6 | 78.4 | 80.4 |
|
| 36 |
+
| DBNet + oCLIP | 85.1 | 81.7 | 83.4 |
|
| 37 |
| **DBNet + MonkeyOCRv2** | **87.7** | 80.1 | **83.7** |
|
| 38 |
|
| 39 |
### CTW1500
|
| 40 |
|
| 41 |
+
| Method | P | R | F |
|
| 42 |
+
| ------------------------ | -------: | ---: | -------: |
|
| 43 |
+
| PSENet (ResNet-50) | 80.1 | 82.7 | 81.4 |
|
| 44 |
+
| PSENet + oCLIP | 82.1 | 85.5 | 83.8 |
|
| 45 |
| **PSENet + MonkeyOCRv2** | **88.3** | 82.0 | **85.1** |
|
| 46 |
|
| 47 |
### ICDAR2015
|
| 48 |
|
| 49 |
+
| Method | P | R | F |
|
| 50 |
+
| ------------------------ | -------: | -------: | -------: |
|
| 51 |
+
| PSENet (ResNet-50) | 84.0 | 76.2 | 79.9 |
|
| 52 |
+
| PSENet + oCLIP | 87.3 | 82.6 | 84.9 |
|
| 53 |
+
| **PSENet + MonkeyOCRv2** | **90.4** | 80.3 | **85.0** |
|
| 54 |
+
| DBNet (ResNet-50) | 88.8 | 81.5 | 85.0 |
|
| 55 |
+
| DBNet + oCLIP | 90.9 | 84.1 | 87.4 |
|
| 56 |
+
| **DBNet + MonkeyOCRv2** | **91.2** | **86.0** | **88.5** |
|
| 57 |
|
| 58 |
### Checkpoints
|
| 59 |
|
| 60 |
Download the checkpoints from
|
| 61 |
+
[HB16888/MonkeyOCRv2\_det](https://huggingface.co/HB16888/MonkeyOCRv2_det)
|
| 62 |
(HuggingFace) or
|
| 63 |
+
[WangXinhan/MonkeyOCRv2\_det](https://modelscope.cn/models/WangXinhan/MonkeyOCRv2_det)
|
| 64 |
(ModelScope):
|
| 65 |
|
| 66 |
```bash
|
|
|
|
| 73 |
Each checkpoint is the best epoch on the test set, i.e. exactly the row
|
| 74 |
reported in the tables above.
|
| 75 |
|
| 76 |
+
| Checkpoint | Method | Dataset | Epoch | Config |
|
| 77 |
+
| -------------------------------- | -------------------- | ---------- | ----: | -------------------------------------------------------------------------------- |
|
| 78 |
+
| dbnet\_r50\_totaltext.pth | DBNet baseline | Total-Text | 580 | configs/textdet/dbnet/dbnet\_resnet50\_1200e\_totaltext\_2gpu.py |
|
| 79 |
+
| dbnet\_r50-oclip\_totaltext.pth | DBNet + oCLIP | Total-Text | 740 | configs/textdet/dbnet/dbnet\_resnet50-oclip\_1200e\_totaltext\_2gpu.py |
|
| 80 |
+
| dbnet\_mkv2vitae\_totaltext.pth | DBNet + MonkeyOCRv2 | Total-Text | 1000 | configs/textdet/dbnet/dbnet\_mkv2vitae\_1200e\_totaltext\_2gpu\_adamw\.py |
|
| 81 |
+
| psenet\_r50\_ctw1500.pth | PSENet baseline | CTW1500 | 280 | configs/textdet/psenet/psenet\_resnet50\_fpnf\_600e\_ctw1500\_2gpu.py |
|
| 82 |
+
| psenet\_r50-oclip\_ctw1500.pth | PSENet + oCLIP | CTW1500 | 280 | configs/textdet/psenet/psenet\_resnet50-oclip\_fpnf\_600e\_ctw1500\_2gpu.py |
|
| 83 |
+
| psenet\_mkv2vitae\_ctw1500.pth | PSENet + MonkeyOCRv2 | CTW1500 | 120 | configs/textdet/psenet/psenet\_mkv2vitae\_fpnf\_600e\_ctw1500\_4gpu\_adamw\.py |
|
| 84 |
+
| psenet\_r50\_icdar2015.pth | PSENet baseline | ICDAR2015 | 400 | configs/textdet/psenet/psenet\_resnet50\_fpnf\_600e\_icdar2015\_2gpu.py |
|
| 85 |
+
| psenet\_r50-oclip\_icdar2015.pth | PSENet + oCLIP | ICDAR2015 | 520 | configs/textdet/psenet/psenet\_resnet50-oclip\_fpnf\_600e\_icdar2015\_2gpu.py |
|
| 86 |
+
| psenet\_mkv2vitae\_icdar2015.pth | PSENet + MonkeyOCRv2 | ICDAR2015 | 160 | configs/textdet/psenet/psenet\_mkv2vitae\_fpnf\_600e\_icdar2015\_4gpu\_adamw\.py |
|
| 87 |
+
| dbnet\_r50\_icdar2015.pth | DBNet baseline | ICDAR2015 | 980 | configs/textdet/dbnet/dbnet\_resnet50\_1200e\_icdar2015\_2gpu.py |
|
| 88 |
+
| dbnet\_r50-oclip\_icdar2015.pth | DBNet + oCLIP | ICDAR2015 | 1100 | configs/textdet/dbnet/dbnet\_resnet50-oclip\_1200e\_icdar2015\_2gpu.py |
|
| 89 |
+
| dbnet\_mkv2vitae\_icdar2015.pth | DBNet + MonkeyOCRv2 | ICDAR2015 | 420 | configs/textdet/dbnet/dbnet\_mkv2vitae\_1200e\_icdar2015\_2gpu\_adamw\.py |
|
| 90 |
|
| 91 |
## Environment
|
| 92 |
|
|
|
|
| 103 |
bash install.sh # clones MMOCR v1.0.1 into ./mmocr and patches it
|
| 104 |
```
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
## Pretrained Backbone
|
| 107 |
|
| 108 |
Download the MonkeyOCRv2-AS visual encoder before training or evaluation:
|
|
|
|
| 111 |
hf download zenosai/MonkeyOCRv2-AS --local-dir ./pretrained/monkeyocrv2_as
|
| 112 |
```
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
## Datasets
|
| 115 |
|
| 116 |
```bash
|
|
|
|
| 174 |
bash tools/dist_train.sh configs/textdet/dbnet/dbnet_mkv2vitae_1200e_icdar2015_2gpu_adamw.py 2
|
| 175 |
```
|
| 176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
## Evaluation
|
| 178 |
|
| 179 |
```bash
|
|
|
|
| 194 |
## Acknowledgements
|
| 195 |
|
| 196 |
This project builds on [MMOCR](https://github.com/open-mmlab/mmocr),
|
| 197 |
+
[DBNet](https://github.com/MhLiao/DB),
|
| 198 |
+
[PSENet](https://github.com/whai362/PSENet),
|
| 199 |
+
[oCLIP](https://github.com/bytedance/oclip), and
|
| 200 |
+
[MonkeyOCRv2](https://github.com/Yuliang-Liu/MonkeyOCRv2).
|