MCPcopy
hub / github.com/PaddlePaddle/PaddleOCR / __init__

Method __init__

ppocr/modeling/backbones/rec_svtrnet.py:420–587  ·  view source on GitHub ↗
(
        self,
        img_size=[32, 100],
        in_channels=3,
        embed_dim=[64, 128, 256],
        depth=[3, 6, 3],
        num_heads=[2, 4, 8],
        mixer=["Local"] * 6 + ["Global"] * 6,  # Local atten, Global atten, Conv
        local_mixer=[[7, 11], [7, 11], [7, 11]],
        patch_merging="Conv",  # Conv, Pool, None
        mlp_ratio=4,
        qkv_bias=True,
        qk_scale=None,
        drop_rate=0.0,
        last_drop=0.1,
        attn_drop_rate=0.0,
        drop_path_rate=0.1,
        norm_layer="nn.LayerNorm",
        sub_norm="nn.LayerNorm",
        epsilon=1e-6,
        out_channels=192,
        out_char_num=25,
        block_unit="Block",
        act="nn.GELU",
        last_stage=True,
        sub_num=2,
        prenorm=True,
        use_lenhead=False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

418
419class SVTRNet(nn.Layer):
420 def __init__(
421 self,
422 img_size=[32, 100],
423 in_channels=3,
424 embed_dim=[64, 128, 256],
425 depth=[3, 6, 3],
426 num_heads=[2, 4, 8],
427 mixer=["Local"] * 6 + ["Global"] * 6, # Local atten, Global atten, Conv
428 local_mixer=[[7, 11], [7, 11], [7, 11]],
429 patch_merging="Conv", # Conv, Pool, None
430 mlp_ratio=4,
431 qkv_bias=True,
432 qk_scale=None,
433 drop_rate=0.0,
434 last_drop=0.1,
435 attn_drop_rate=0.0,
436 drop_path_rate=0.1,
437 norm_layer="nn.LayerNorm",
438 sub_norm="nn.LayerNorm",
439 epsilon=1e-6,
440 out_channels=192,
441 out_char_num=25,
442 block_unit="Block",
443 act="nn.GELU",
444 last_stage=True,
445 sub_num=2,
446 prenorm=True,
447 use_lenhead=False,
448 **kwargs,
449 ):
450 super().__init__()
451 self.img_size = img_size
452 self.embed_dim = embed_dim
453 self.out_channels = out_channels
454 self.prenorm = prenorm
455 patch_merging = (
456 None
457 if patch_merging != "Conv" and patch_merging != "Pool"
458 else patch_merging
459 )
460 self.patch_embed = PatchEmbed(
461 img_size=img_size,
462 in_channels=in_channels,
463 embed_dim=embed_dim[0],
464 sub_num=sub_num,
465 )
466 num_patches = self.patch_embed.num_patches
467 self.HW = [img_size[0] // (2**sub_num), img_size[1] // (2**sub_num)]
468 self.pos_embed = self.create_parameter(
469 shape=[1, num_patches, embed_dim[0]], default_initializer=zeros_
470 )
471 self.add_parameter("pos_embed", self.pos_embed)
472 self.pos_drop = nn.Dropout(p=drop_rate)
473 Block_unit = eval(block_unit)
474
475 dpr = np.linspace(0, drop_path_rate, sum(depth))
476 self.blocks1 = nn.LayerList(
477 [

Callers

nothing calls this directly

Calls 5

SubSampleClass · 0.85
PatchEmbedClass · 0.70
evalFunction · 0.50
__init__Method · 0.45
applyMethod · 0.45

Tested by

no test coverage detected