(
self,
image_size,
in_channels,
model_channels,
out_channels,
num_res_blocks,
attention_resolutions,
dropout=0,
channel_mult=(1, 2, 4, 8),
conv_resample=True,
dims=2,
use_checkpoint=False,
use_fp16=False,
num_heads=1,
num_head_channels=-1,
num_heads_upsample=-1,
use_scale_shift_norm=False,
resblock_updown=False,
use_new_attention_order=False,
pool="adaptive",
)
| 759 | """ |
| 760 | |
| 761 | def __init__( |
| 762 | self, |
| 763 | image_size, |
| 764 | in_channels, |
| 765 | model_channels, |
| 766 | out_channels, |
| 767 | num_res_blocks, |
| 768 | attention_resolutions, |
| 769 | dropout=0, |
| 770 | channel_mult=(1, 2, 4, 8), |
| 771 | conv_resample=True, |
| 772 | dims=2, |
| 773 | use_checkpoint=False, |
| 774 | use_fp16=False, |
| 775 | num_heads=1, |
| 776 | num_head_channels=-1, |
| 777 | num_heads_upsample=-1, |
| 778 | use_scale_shift_norm=False, |
| 779 | resblock_updown=False, |
| 780 | use_new_attention_order=False, |
| 781 | pool="adaptive", |
| 782 | ): |
| 783 | super().__init__() |
| 784 | |
| 785 | if num_heads_upsample == -1: |
| 786 | num_heads_upsample = num_heads |
| 787 | |
| 788 | self.in_channels = in_channels |
| 789 | self.model_channels = model_channels |
| 790 | self.out_channels = out_channels |
| 791 | self.num_res_blocks = num_res_blocks |
| 792 | self.attention_resolutions = attention_resolutions |
| 793 | self.dropout = dropout |
| 794 | self.channel_mult = channel_mult |
| 795 | self.conv_resample = conv_resample |
| 796 | self.use_checkpoint = use_checkpoint |
| 797 | self.dtype = th.float16 if use_fp16 else th.float32 |
| 798 | self.num_heads = num_heads |
| 799 | self.num_head_channels = num_head_channels |
| 800 | self.num_heads_upsample = num_heads_upsample |
| 801 | |
| 802 | time_embed_dim = model_channels * 4 |
| 803 | self.time_embed = nn.Sequential( |
| 804 | linear(model_channels, time_embed_dim), |
| 805 | nn.SiLU(), |
| 806 | linear(time_embed_dim, time_embed_dim), |
| 807 | ) |
| 808 | |
| 809 | ch = int(channel_mult[0] * model_channels) |
| 810 | self.input_blocks = nn.ModuleList( |
| 811 | [TimestepEmbedSequential(conv_nd(dims, in_channels, ch, 3, padding=1))] |
| 812 | ) |
| 813 | self._feature_size = ch |
| 814 | input_block_chans = [ch] |
| 815 | ds = 1 |
| 816 | for level, mult in enumerate(channel_mult): |
| 817 | for _ in range(num_res_blocks): |
| 818 | layers = [ |
nothing calls this directly
no test coverage detected