MCPcopy Create free account
hub / github.com/aigc3d/LHM / __init__

Method __init__

engine/BiRefNet/models/birefnet.py:233–349  ·  view source on GitHub ↗
(self, channels)

Source from the content-addressed store, hash-verified

231
232class Decoder(nn.Module):
233 def __init__(self, channels):
234 super(Decoder, self).__init__()
235 self.config = Config()
236 DecoderBlock = eval(self.config.dec_blk)
237 LateralBlock = eval(self.config.lat_blk)
238
239 if self.config.dec_ipt:
240 self.split = self.config.dec_ipt_split
241 N_dec_ipt = 64
242 DBlock = SimpleConvs
243 ic = 64
244 ipt_cha_opt = 1
245 self.ipt_blk5 = DBlock(
246 2**10 * 3 if self.split else 3,
247 [N_dec_ipt, channels[0] // 8][ipt_cha_opt],
248 inter_channels=ic,
249 )
250 self.ipt_blk4 = DBlock(
251 2**8 * 3 if self.split else 3,
252 [N_dec_ipt, channels[0] // 8][ipt_cha_opt],
253 inter_channels=ic,
254 )
255 self.ipt_blk3 = DBlock(
256 2**6 * 3 if self.split else 3,
257 [N_dec_ipt, channels[1] // 8][ipt_cha_opt],
258 inter_channels=ic,
259 )
260 self.ipt_blk2 = DBlock(
261 2**4 * 3 if self.split else 3,
262 [N_dec_ipt, channels[2] // 8][ipt_cha_opt],
263 inter_channels=ic,
264 )
265 self.ipt_blk1 = DBlock(
266 2**0 * 3 if self.split else 3,
267 [N_dec_ipt, channels[3] // 8][ipt_cha_opt],
268 inter_channels=ic,
269 )
270 else:
271 self.split = None
272
273 self.decoder_block4 = DecoderBlock(
274 channels[0]
275 + (
276 [N_dec_ipt, channels[0] // 8][ipt_cha_opt] if self.config.dec_ipt else 0
277 ),
278 channels[1],
279 )
280 self.decoder_block3 = DecoderBlock(
281 channels[1]
282 + (
283 [N_dec_ipt, channels[0] // 8][ipt_cha_opt] if self.config.dec_ipt else 0
284 ),
285 channels[2],
286 )
287 self.decoder_block2 = DecoderBlock(
288 channels[2]
289 + (
290 [N_dec_ipt, channels[1] // 8][ipt_cha_opt] if self.config.dec_ipt else 0

Callers 3

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 2

ConfigClass · 0.90
evalFunction · 0.50

Tested by

no test coverage detected