MCPcopy Create free account
hub / github.com/IceClear/StableSR / forward

Method forward

ldm/modules/diffusionmodules/model.py:534–567  ·  view source on GitHub ↗
(self, x, return_fea=False)

Source from the content-addressed store, hash-verified

532 padding=1)
533
534 def forward(self, x, return_fea=False):
535 # timestep embedding
536 temb = None
537
538 # downsampling
539 hs = [self.conv_in(x)]
540 fea_list = []
541 for i_level in range(self.num_resolutions):
542 for i_block in range(self.num_res_blocks):
543 h = self.down[i_level].block[i_block](hs[-1], temb)
544 if len(self.down[i_level].attn) > 0:
545 h = self.down[i_level].attn[i_block](h)
546 hs.append(h)
547 if return_fea:
548 if i_level==1 or i_level==2:
549 fea_list.append(h)
550 if i_level != self.num_resolutions-1:
551 hs.append(self.down[i_level].downsample(hs[-1]))
552
553 # middle
554 h = hs[-1]
555 h = self.mid.block_1(h, temb)
556 h = self.mid.attn_1(h)
557 h = self.mid.block_2(h, temb)
558
559 # end
560 h = self.norm_out(h)
561 h = nonlinearity(h)
562 h = self.conv_out(h)
563
564 if return_fea:
565 return h, fea_list
566
567 return h
568
569class Decoder(nn.Module):
570 def __init__(self, *, ch, out_ch, ch_mult=(1,2,4,8), num_res_blocks,

Callers

nothing calls this directly

Calls 2

nonlinearityFunction · 0.85
downsampleMethod · 0.80

Tested by

no test coverage detected