Skip to content

Commit c6580a4

Browse files
authored
[Dataset Preparer] SynthText (#1779)
* [Dataset] Support Synthtext * update * update * finalize setting * fix * textrec * update * add fake magnet obtainer * update rec * update * sample_ann
1 parent 7ef34c4 commit c6580a4

File tree

9 files changed

+400
-94
lines changed

9 files changed

+400
-94
lines changed
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
synthtext_textdet_data_root = 'data/det/synthtext'
1+
synthtext_textdet_data_root = 'data/synthtext'
22

33
synthtext_textdet_train = dict(
44
type='OCRDataset',
55
data_root=synthtext_textdet_data_root,
6-
ann_file='instances_training.json',
7-
data_prefix=dict(img_path='imgs/'),
6+
ann_file='textdet_train.json',
87
filter_cfg=dict(filter_empty_gt=True, min_size=32),
98
pipeline=None)
10-
11-
synthtext_textdet_test = dict(
12-
type='OCRDataset',
13-
data_root=synthtext_textdet_data_root,
14-
ann_file='instances_test.json',
15-
data_prefix=dict(img_path='imgs/'),
16-
test_mode=True,
17-
pipeline=None)
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
synthtext_textrecog_data_root = 'data/rec/SynthText/'
1+
synthtext_textrecog_data_root = 'data/synthtext'
22

33
synthtext_textrecog_train = dict(
44
type='OCRDataset',
55
data_root=synthtext_textrecog_data_root,
6-
data_prefix=dict(img_path='synthtext/SynthText_patch_horizontal'),
7-
ann_file='train_labels.json',
8-
test_mode=False,
6+
ann_file='textrecog_train.json',
97
pipeline=None)
108

11-
synthtext_an_textrecog_train = dict(
9+
synthtext_sub_textrecog_train = dict(
1210
type='OCRDataset',
1311
data_root=synthtext_textrecog_data_root,
14-
data_prefix=dict(img_path='synthtext/SynthText_patch_horizontal'),
15-
ann_file='alphanumeric_train_labels.json',
16-
test_mode=False,
12+
ann_file='subset_textrecog_train.json',
1713
pipeline=None)
1814

19-
synthtext_sub_textrecog_train = dict(
15+
synthtext_an_textrecog_train = dict(
2016
type='OCRDataset',
2117
data_root=synthtext_textrecog_data_root,
22-
data_prefix=dict(img_path='synthtext/SynthText_patch_horizontal'),
23-
ann_file='subset_train_labels.json',
24-
test_mode=False,
18+
ann_file='alphanumeric_textrecog_train.json',
2519
pipeline=None)
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
**Text Detection/Recognition/Spotting**
2+
3+
```json
4+
{
5+
"imnames": [['8/ballet_106_0.jpg', ...]],
6+
"wordBB": [[[420.58957 418.85016 448.08478 410.3094 117.745026
7+
322.30963 322.6857 159.09138 154.27284 260.14597
8+
431.9315 427.52274 296.86508 99.56819 108.96211 ]
9+
[512.3321 431.88342 519.4515 499.81183 179.0544
10+
377.97382 376.4993 203.64464 193.77492 313.61514
11+
487.58023 484.64633 365.83176 142.49403 144.90457 ]
12+
[511.92203 428.7077 518.7375 499.0373 172.1684
13+
378.35858 377.2078 203.3191 193.0739 319.69186
14+
485.6758 482.571 365.76303 142.31898 144.43858 ]
15+
[420.1795 415.67444 447.3708 409.53485 110.859024
16+
322.6944 323.3942 158.76585 153.57182 266.2227
17+
430.02707 425.44742 296.79636 99.39314 108.49613 ]]
18+
19+
[[ 21.06382 46.19922 47.570374 73.95366 197.17792
20+
9.993624 48.437763 9.064571 49.659035 208.57095
21+
118.41646 162.82489 29.548729 5.800581 28.812992 ]
22+
[ 23.069519 48.254295 50.130234 77.18146 208.71487
23+
8.999153 46.69632 9.698633 50.869553 203.25742
24+
122.64043 168.38647 29.660484 6.2558594 29.602367 ]
25+
[ 41.827087 68.39458 70.03627 98.65903 245.30832
26+
30.534437 68.589294 32.57161 73.74529 264.40634
27+
147.7303 189.70224 72.08 22.759935 50.81941 ]
28+
[ 39.82139 66.3395 67.47641 95.43123 233.77136
29+
31.528908 70.33074 31.937548 72.534775 269.71988
30+
143.50633 184.14066 71.96825 22.304657 50.030033 ]], ...],
31+
"charBB": [[[423.16126397 439.60847343 450.66887979 466.31976402 479.76190495
32+
504.59927448 418.80489444 450.13965942 464.16775197 480.46891089
33+
502.46437709 413.02373632 433.01396211 446.7222192 470.28467827
34+
482.51674486 116.52285438 139.51408587 150.7448586 162.03366629
35+
322.84717946 333.54881536 343.28386485 363.07416389 323.48968759
36+
337.98503283 356.66355903 160.48517048 174.1707753 189.64454066
37+
155.7637383 167.45490471 179.63644201 262.2183876 271.75848874
38+
284.05396524 298.26103738 432.8464733 449.15387392 468.07231897
39+
428.11482147 445.61538159 469.24565878 296.86441324 323.6603118
40+
344.09880401 101.14677814 110.45423597 120.54555495 131.18342618
41+
132.20545124 110.01673682 120.83144568 131.35885673]
42+
[438.2997574 452.61288403 466.31976402 482.22585715 498.3934528
43+
512.20555863 431.88338084 466.11639619 481.73414937 499.62012025
44+
519.36789779 432.51717267 449.23571387 465.73425964 484.45139112
45+
499.59056304 140.27413679 149.59811175 160.13352083 169.59504507
46+
333.55849014 344.33923741 361.08275796 378.09844418 339.92898685
47+
355.57692063 376.51230484 174.1707753 189.07871028 203.64462646
48+
165.22739457 181.27572412 193.60260894 270.99557614 283.13281739
49+
298.75499435 313.61511672 447.1421735 470.27065563 487.02126631
50+
446.97485257 468.98979567 484.64633864 317.88691577 341.16094163
51+
365.8300006 111.15280603 120.54555495 130.72086821 135.27663717
52+
142.4726875 120.1331955 133.07976304 144.75919258]
53+
[435.54895424 449.95797159 464.5848793 480.68235876 497.04793842
54+
511.1101386 428.95660757 463.61882066 480.14247127 498.2535215
55+
518.03243928 429.36600266 447.19056345 463.89483785 482.21016814
56+
498.18529977 142.63162835 152.55587851 162.80539142 172.21885945
57+
333.35620309 344.09880401 360.86201193 377.82379299 339.7646859
58+
355.37508239 376.1110999 172.46032372 187.37816388 201.39094518
59+
163.04321987 178.99078221 191.89681939 275.3073355 286.08373072
60+
301.85539131 318.57227103 444.54207279 467.53925436 485.27070558
61+
444.57367155 466.90671029 482.56302723 317.62908407 340.9131681
62+
365.44465854 109.40501176 119.4999228 129.67892444 134.35253232
63+
140.97421069 118.61779828 131.34019115 143.25688164]
64+
[420.17946701 436.74150236 448.74896556 464.5848793 478.18853922
65+
503.4152019 415.67442461 447.3707845 462.35927516 478.8614766
66+
500.86810735 409.54560397 430.77026495 444.64606264 467.79077782
67+
480.89051912 119.14629674 142.63162835 153.56593297 164.78799774
68+
322.69436747 333.35620309 343.11884239 362.84714115 323.37931952
69+
337.83763574 356.35573621 158.76583616 172.46032372 187.37816388
70+
153.57183805 165.15781218 177.92125239 266.22269514 274.45156305
71+
286.82608962 302.69695881 430.02705241 446.01814255 466.05208347
72+
425.44741792 443.19481667 466.90671029 296.79634428 323.49707084
73+
343.82488703 99.39315359 109.40501176 119.4999228 130.25798537
74+
130.70149005 108.49612777 119.08444238 129.84935461]]
75+
76+
[[ 22.26958901 21.60559248 27.0241972 27.25747678 27.45783459
77+
28.73896576 47.91255579 47.80732383 53.77711568 54.24219042
78+
52.00169325 74.79043429 80.45929285 81.04748707 76.11658669
79+
82.58335942 203.67278213 201.2743445 205.59358622 205.51198143
80+
10.06536976 10.82312635 16.77203865 16.31842372 54.80444433
81+
54.66492 47.33822371 15.08534083 15.18716407 9.62607092
82+
51.06813224 50.18928243 56.16019366 220.78902143 236.08062638
83+
231.69267533 209.73652786 124.25352842 119.99631725 128.73732717
84+
165.78411123 167.31764153 167.05531699 29.97351822 31.5116502
85+
31.14650552 5.88513488 12.51324147 12.57920537 8.21515307
86+
8.21998849 35.66412031 29.17945741 36.00660903]
87+
[ 22.46075572 21.76391911 27.25747678 27.49456029 27.73554156
88+
28.85582217 48.25428361 48.21714995 54.27828788 54.78857757
89+
52.4595556 75.57743634 81.15533616 81.86325615 76.681392
90+
83.31596322 210.04771309 203.83983042 208.00417391 207.41791524
91+
9.79265706 10.55231862 16.36406888 15.97405105 54.64620856
92+
54.49559004 47.09756263 15.18716407 15.29808166 9.69862498
93+
51.27597632 50.48652154 56.49239954 216.92183074 232.02141018
94+
226.44624213 203.25738931 125.19349641 121.32658508 130.00428964
95+
167.43676857 169.36588297 168.38645076 29.58279603 31.19899202
96+
30.75826599 5.92344996 12.57920537 12.64571832 8.23451892
97+
8.26856497 35.82646468 29.342662 36.22165159]
98+
[ 40.15739982 40.47241401 40.79219178 41.14411963 41.50190876
99+
41.80934074 66.81590976 68.05921213 68.6519006 69.30152766
100+
70.01097963 96.14641662 96.04484417 96.89110144 97.81897661
101+
98.62829468 237.26055111 240.35280825 243.54641271 245.04022528
102+
31.33842788 31.14650552 30.84702178 30.54399042 69.80098672
103+
68.7212013 68.62479627 32.13243303 32.34474067 32.54416771
104+
72.82501686 73.31372392 73.70922459 267.74318222 265.39839711
105+
259.52741156 253.14023308 144.60810334 145.23371653 147.69958337
106+
186.00278322 188.17713786 189.70144388 71.89351759 53.62266986
107+
54.40060855 22.41084398 22.51791234 22.62587258 17.11356079
108+
22.74567232 50.25232032 46.05692507 50.79345235]
109+
[ 39.82138755 40.18347166 40.44598236 40.79219178 41.08959901
110+
41.64111176 66.33948982 67.47640971 68.01403337 68.60595247
111+
69.3953105 95.13188979 95.21297344 95.91593691 97.08847413
112+
97.75212171 229.94285119 237.26055111 240.66752705 242.74145162
113+
31.52890731 31.33842788 31.16401306 30.81155638 69.87135926
114+
68.80273568 68.71664209 31.93753588 32.13243303 32.34474067
115+
72.53476992 72.88981775 73.28094858 269.71986636 267.92938572
116+
262.93698624 256.88902439 143.50635029 143.61251781 146.24080653
117+
184.14064261 185.86853729 188.17713786 71.96823746 53.79651809
118+
54.60870874 22.30465649 22.41084398 22.51791234 17.07939535
119+
22.63671808 50.03002471 45.81009198 50.49899163]], ...],
120+
"txt": [['Lines:\nI lost\nKevin ' 'will ' 'line\nand '
121+
'and\nthe ' '(and ' 'the\nout '
122+
'you ' "don't\n pkg "], ...]
123+
}
124+
```

dataset_zoo/synthtext/textdet.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
data_root = 'data/synthtext'
2+
cache_path = 'data/cache'
3+
4+
train_preparer = dict(
5+
obtainer=dict(
6+
type='NaiveDataObtainer',
7+
cache_path=cache_path,
8+
files=[
9+
dict(
10+
url='magnet:?xt=urn:btih:2dba9518166cbd141534cbf381aa3e99a08'
11+
'7e83c&tr=https%3A%2F%2Facademictorrents.com%2Fannounce.php&t'
12+
'r=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2F'
13+
'tracker.opentrackr.org%3A1337%2Fannounce',
14+
save_name='SynthText.zip',
15+
md5='8ae0309c80ff882f9d6ba5ea62cdb556',
16+
split=['train'],
17+
content=['image', 'annotation'],
18+
mapping=[['SynthText/SynthText/*', 'textdet_imgs/train/'],
19+
['textdet_imgs/train/gt.mat', 'annotations/gt.mat']]),
20+
]),
21+
gatherer=dict(type='MonoGatherer', ann_name='gt.mat'),
22+
parser=dict(type='SynthTextAnnParser'),
23+
packer=dict(type='TextDetPacker'),
24+
dumper=dict(type='JsonDumper'),
25+
)
26+
27+
delete = ['SynthText', 'annotations']
28+
29+
config_generator = dict(
30+
type='TextDetConfigGenerator', data_root=data_root, test_anns=None)

dataset_zoo/synthtext/textrecog.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
_base_ = ['textdet.py']
2+
3+
_base_.train_preparer.obtainer.files.append(
4+
dict(
5+
url='https://download.openmmlab.com/mmocr/data/1.x/recog/'
6+
'SynthText/subset_textrecog_train.json',
7+
save_name='subset_textrecog_train.json',
8+
md5='151c4edd1cc240362046d3a6f8f4b4c6',
9+
split=['train'],
10+
content=['annotation']))
11+
_base_.train_preparer.obtainer.files.append(
12+
dict(
13+
url='https://download.openmmlab.com/mmocr/data/1.x/recog/'
14+
'SynthText/alphanumeric_textrecog_train.json',
15+
save_name='alphanumeric_textrecog_train.json',
16+
md5='89b80163435794ca117a124d081d68a9',
17+
split=['train'],
18+
content=['annotation']))
19+
_base_.train_preparer.gatherer.img_dir = 'textdet_imgs/train'
20+
_base_.train_preparer.packer.type = 'TextRecogCropPacker'
21+
22+
config_generator = dict(
23+
type='TextRecogConfigGenerator',
24+
train_anns=[
25+
dict(ann_file='textrecog_train.json', dataset_postfix=''),
26+
dict(ann_file='subset_textrecog_train.json', dataset_postfix='sub'),
27+
dict(
28+
ann_file='alphanumeric_textrecog_train.json',
29+
dataset_postfix='an'),
30+
])

0 commit comments

Comments
 (0)