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

Class PixArtAlphaTextProjection

diffsynth/models/stepvideo_dit.py:298–323  ·  view source on GitHub ↗

Projects caption embeddings. Also handles dropout for classifier-free guidance. Adapted from https://github.com/PixArt-alpha/PixArt-alpha/blob/master/diffusion/model/nets/PixArt_blocks.py

Source from the content-addressed store, hash-verified

296
297
298class PixArtAlphaTextProjection(nn.Module):
299 """
300 Projects caption embeddings. Also handles dropout for classifier-free guidance.
301
302 Adapted from https://github.com/PixArt-alpha/PixArt-alpha/blob/master/diffusion/model/nets/PixArt_blocks.py
303 """
304
305 def __init__(self, in_features, hidden_size):
306 super().__init__()
307 self.linear_1 = nn.Linear(
308 in_features,
309 hidden_size,
310 bias=True,
311 )
312 self.act_1 = nn.GELU(approximate="tanh")
313 self.linear_2 = nn.Linear(
314 hidden_size,
315 hidden_size,
316 bias=True,
317 )
318
319 def forward(self, caption):
320 hidden_states = self.linear_1(caption)
321 hidden_states = self.act_1(hidden_states)
322 hidden_states = self.linear_2(hidden_states)
323 return hidden_states
324
325
326class Attention(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected