MCPcopy Index your code
hub / github.com/VisionXLab/OF-Diff / __init__

Method __init__

ldm/modules/diffusionmodules/openaimodel.py:444–738  ·  view source on GitHub ↗
(
        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,
        num_classes=None,
        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,
        use_spatial_transformer=False,    # custom transformer support
        transformer_depth=1,              # custom transformer support
        context_dim=None,                 # custom transformer support
        n_embed=None,                     # custom support for prediction of discrete ids into codebook of first stage vq model
        legacy=True,
        disable_self_attentions=None,
        num_attention_blocks=None,
        disable_middle_self_attn=False,
        use_linear_in_transformer=False,
    )

Source from the content-addressed store, hash-verified

442 """
443
444 def __init__(
445 self,
446 image_size,
447 in_channels,
448 model_channels,
449 out_channels,
450 num_res_blocks,
451 attention_resolutions,
452 dropout=0,
453 channel_mult=(1, 2, 4, 8),
454 conv_resample=True,
455 dims=2,
456 num_classes=None,
457 use_checkpoint=False,
458 use_fp16=False,
459 num_heads=-1,
460 num_head_channels=-1,
461 num_heads_upsample=-1,
462 use_scale_shift_norm=False,
463 resblock_updown=False,
464 use_new_attention_order=False,
465 use_spatial_transformer=False, # custom transformer support
466 transformer_depth=1, # custom transformer support
467 context_dim=None, # custom transformer support
468 n_embed=None, # custom support for prediction of discrete ids into codebook of first stage vq model
469 legacy=True,
470 disable_self_attentions=None,
471 num_attention_blocks=None,
472 disable_middle_self_attn=False,
473 use_linear_in_transformer=False,
474 ):
475 super().__init__()
476 if use_spatial_transformer:
477 assert context_dim is not None, 'Fool!! You forgot to include the dimension of your cross-attention conditioning...'
478
479 if context_dim is not None:
480 assert use_spatial_transformer, 'Fool!! You forgot to use the spatial transformer for your cross-attention conditioning...'
481 from omegaconf.listconfig import ListConfig
482 if type(context_dim) == ListConfig:
483 context_dim = list(context_dim)
484
485 if num_heads_upsample == -1:
486 num_heads_upsample = num_heads
487
488 if num_heads == -1:
489 assert num_head_channels != -1, 'Either num_heads or num_head_channels has to be set'
490
491 if num_head_channels == -1:
492 assert num_heads != -1, 'Either num_heads or num_head_channels has to be set'
493
494 self.image_size = image_size
495 self.in_channels = in_channels
496 self.model_channels = model_channels
497 self.out_channels = out_channels
498 if isinstance(num_res_blocks, int):
499 self.num_res_blocks = len(channel_mult) * [num_res_blocks]
500 else:
501 if len(num_res_blocks) != len(channel_mult):

Callers

nothing calls this directly

Calls 12

linearFunction · 0.90
conv_ndFunction · 0.90
existsFunction · 0.90
SpatialTransformerClass · 0.90
normalizationFunction · 0.90
zero_moduleFunction · 0.90
ResBlockClass · 0.85
AttentionBlockClass · 0.85
DownsampleClass · 0.70
UpsampleClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected