MCPcopy Create free account
hub / github.com/aim-uofa/Framer / UpBlockTemporalDecoder

Class UpBlockTemporalDecoder

models_diffusers/unet_3d_blocks.py:1822–1869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1820
1821
1822class UpBlockTemporalDecoder(nn.Module):
1823 def __init__(
1824 self,
1825 in_channels: int,
1826 out_channels: int,
1827 num_layers: int = 1,
1828 add_upsample: bool = True,
1829 ):
1830 super().__init__()
1831 resnets = []
1832 for i in range(num_layers):
1833 input_channels = in_channels if i == 0 else out_channels
1834
1835 resnets.append(
1836 SpatioTemporalResBlock(
1837 in_channels=input_channels,
1838 out_channels=out_channels,
1839 temb_channels=None,
1840 eps=1e-6,
1841 temporal_eps=1e-5,
1842 merge_factor=0.0,
1843 merge_strategy="learned",
1844 switch_spatial_to_temporal_mix=True,
1845 )
1846 )
1847 self.resnets = nn.ModuleList(resnets)
1848
1849 if add_upsample:
1850 self.upsamplers = nn.ModuleList([Upsample2D(out_channels, use_conv=True, out_channels=out_channels)])
1851 else:
1852 self.upsamplers = None
1853
1854 def forward(
1855 self,
1856 hidden_states: torch.FloatTensor,
1857 image_only_indicator: torch.FloatTensor,
1858 ) -> torch.FloatTensor:
1859 for resnet in self.resnets:
1860 hidden_states = resnet(
1861 hidden_states,
1862 image_only_indicator=image_only_indicator,
1863 )
1864
1865 if self.upsamplers is not None:
1866 for upsampler in self.upsamplers:
1867 hidden_states = upsampler(hidden_states)
1868
1869 return hidden_states
1870
1871
1872class UNetMidBlockSpatioTemporal(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected