Skip to content

Commit 0d44b5b

Browse files
committed
[UPDATE] Replace edict with dict for configuration in anytext.py and RecModel.py for consistency
1 parent 299a646 commit 0d44b5b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

examples/research_projects/anytext/anytext.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,11 @@ def create_predictor(model_dir=None, model_lang="ch", device="cpu", use_fp16=Fal
348348
n_class = 97
349349
else:
350350
raise ValueError(f"Unsupported OCR recog model_lang: {model_lang}")
351-
rec_config = edict(
351+
rec_config = dict(
352352
in_channels=3,
353-
backbone=edict(type="MobileNetV1Enhance", scale=0.5, last_conv_stride=[1, 2], last_pool_type="avg"),
354-
neck=edict(type="SequenceEncoder", encoder_type="svtr", dims=64, depth=2, hidden_dims=120, use_guide=True),
355-
head=edict(type="CTCHead", fc_decay=0.00001, out_channels=n_class, return_feats=True),
353+
backbone=dict(type="MobileNetV1Enhance", scale=0.5, last_conv_stride=[1, 2], last_pool_type="avg"),
354+
neck=dict(type="SequenceEncoder", encoder_type="svtr", dims=64, depth=2, hidden_dims=120, use_guide=True),
355+
head=dict(type="CTCHead", fc_decay=0.00001, out_channels=n_class, return_feats=True),
356356
)
357357

358358
rec_model = RecModel(rec_config)

examples/research_projects/anytext/ocr_recog/RecModel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ class RecModel(nn.Module):
1414
def __init__(self, config):
1515
super().__init__()
1616
assert "in_channels" in config, "in_channels must in model config"
17-
backbone_type = config.backbone.pop("type")
17+
backbone_type = config["backbone"].pop("type")
1818
assert backbone_type in backbone_dict, f"backbone.type must in {backbone_dict}"
19-
self.backbone = backbone_dict[backbone_type](config.in_channels, **config.backbone)
19+
self.backbone = backbone_dict[backbone_type](config['in_channels'], **config['backbone'])
2020

21-
neck_type = config.neck.pop("type")
21+
neck_type = config['neck'].pop("type")
2222
assert neck_type in neck_dict, f"neck.type must in {neck_dict}"
23-
self.neck = neck_dict[neck_type](self.backbone.out_channels, **config.neck)
23+
self.neck = neck_dict[neck_type](self.backbone.out_channels, **config['neck'])
2424

25-
head_type = config.head.pop("type")
25+
head_type = config['head'].pop("type")
2626
assert head_type in head_dict, f"head.type must in {head_dict}"
27-
self.head = head_dict[head_type](self.neck.out_channels, **config.head)
27+
self.head = head_dict[head_type](self.neck.out_channels, **config['head'])
2828

2929
self.name = f"RecModel_{backbone_type}_{neck_type}_{head_type}"
3030

0 commit comments

Comments
 (0)