MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / __init__

Method __init__

diffsynth/models/sdxl_text_encoder.py:6–22  ·  view source on GitHub ↗
(self, embed_dim=768, vocab_size=49408, max_position_embeddings=77, num_encoder_layers=11, encoder_intermediate_size=3072)

Source from the content-addressed store, hash-verified

4
5class SDXLTextEncoder(torch.nn.Module):
6 def __init__(self, embed_dim=768, vocab_size=49408, max_position_embeddings=77, num_encoder_layers=11, encoder_intermediate_size=3072):
7 super().__init__()
8
9 # token_embedding
10 self.token_embedding = torch.nn.Embedding(vocab_size, embed_dim)
11
12 # position_embeds (This is a fixed tensor)
13 self.position_embeds = torch.nn.Parameter(torch.zeros(1, max_position_embeddings, embed_dim))
14
15 # encoders
16 self.encoders = torch.nn.ModuleList([CLIPEncoderLayer(embed_dim, encoder_intermediate_size) for _ in range(num_encoder_layers)])
17
18 # attn_mask
19 self.attn_mask = self.attention_mask(max_position_embeddings)
20
21 # The text encoder is different to that in Stable Diffusion 1.x.
22 # It does not include final_layer_norm.
23
24 def attention_mask(self, length):
25 mask = torch.empty(length, length)

Callers 1

__init__Method · 0.45

Calls 2

attention_maskMethod · 0.95
CLIPEncoderLayerClass · 0.85

Tested by

no test coverage detected