MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / __init__

Method __init__

models/builder.py:61–198  ·  view source on GitHub ↗
(
        self,
        cfg=None,
        criterion=nn.CrossEntropyLoss(reduction="none", ignore_index=255),
        norm_layer=nn.BatchNorm2d,
        syncbn=False,
    )

Source from the content-addressed store, hash-verified

59
60class EncoderDecoder(nn.Module):
61 def __init__(
62 self,
63 cfg=None,
64 criterion=nn.CrossEntropyLoss(reduction="none", ignore_index=255),
65 norm_layer=nn.BatchNorm2d,
66 syncbn=False,
67 ):
68 super(EncoderDecoder, self).__init__()
69 self.norm_layer = norm_layer
70 self.cfg = cfg
71
72 if cfg.backbone == "DFormer-Large":
73 from .encoders.DFormer import DFormer_Large as backbone
74
75 self.channels = [96, 192, 288, 576]
76 elif cfg.backbone == "DFormer-Base":
77 from .encoders.DFormer import DFormer_Base as backbone
78
79 self.channels = [64, 128, 256, 512]
80 elif cfg.backbone == "DFormer-Small":
81 from .encoders.DFormer import DFormer_Small as backbone
82
83 self.channels = [64, 128, 256, 512]
84 elif cfg.backbone == "DFormer-Tiny":
85 from .encoders.DFormer import DFormer_Tiny as backbone
86
87 self.channels = [32, 64, 128, 256]
88
89 elif cfg.backbone == "DFormerv2_L":
90 from .encoders.DFormerv2 import DFormerv2_L as backbone
91
92 self.channels = [112, 224, 448, 640]
93 elif cfg.backbone == "DFormerv2_B":
94 from .encoders.DFormerv2 import DFormerv2_B as backbone
95
96 self.channels = [80, 160, 320, 512]
97 elif cfg.backbone == "DFormerv2_S":
98 from .encoders.DFormerv2 import DFormerv2_S as backbone
99
100 self.channels = [64, 128, 256, 512]
101
102 # DFormer++ (TPAMI 2026): depth-guided local-global attention encoder
103 elif cfg.backbone in ("DFormer++-T", "DFormerPP-T"):
104 from .encoders.DFormerPP import DFormerPP_T as backbone
105
106 self.channels = [48, 96, 192, 384]
107 elif cfg.backbone in ("DFormer++-S", "DFormerPP-S"):
108 from .encoders.DFormerPP import DFormerPP_S as backbone
109
110 self.channels = [72, 144, 288, 576]
111 elif cfg.backbone in ("DFormer++-B", "DFormerPP-B"):
112 from .encoders.DFormerPP import DFormerPP_B as backbone
113
114 self.channels = [72, 144, 288, 576]
115 else:
116 raise NotImplementedError
117
118 if syncbn:

Callers

nothing calls this directly

Calls 4

init_weightsMethod · 0.95
DecoderHeadClass · 0.50
FCNHeadClass · 0.50
UPerHeadClass · 0.50

Tested by

no test coverage detected