MCPcopy Create free account
hub / github.com/Francis-Rings/MotionFollower / __init__

Method __init__

src/models/motion_module.py:185–233  ·  view source on GitHub ↗
(
        self,
        dim,
        num_attention_heads,
        attention_head_dim,
        attention_block_types=(
            "Temporal_Self",
            "Temporal_Self",
        ),
        dropout=0.0,
        norm_num_groups=32,
        cross_attention_dim=768,
        activation_fn="geglu",
        attention_bias=False,
        upcast_attention=False,
        cross_frame_attention_mode=None,
        temporal_position_encoding=False,
        temporal_position_encoding_max_len=24,
    )

Source from the content-addressed store, hash-verified

183
184class TemporalTransformerBlock(nn.Module):
185 def __init__(
186 self,
187 dim,
188 num_attention_heads,
189 attention_head_dim,
190 attention_block_types=(
191 "Temporal_Self",
192 "Temporal_Self",
193 ),
194 dropout=0.0,
195 norm_num_groups=32,
196 cross_attention_dim=768,
197 activation_fn="geglu",
198 attention_bias=False,
199 upcast_attention=False,
200 cross_frame_attention_mode=None,
201 temporal_position_encoding=False,
202 temporal_position_encoding_max_len=24,
203 ):
204 super().__init__()
205
206 attention_blocks = []
207 norms = []
208
209 for block_name in attention_block_types:
210 attention_blocks.append(
211 VersatileAttention(
212 attention_mode=block_name.split("_")[0],
213 cross_attention_dim=cross_attention_dim
214 if block_name.endswith("_Cross")
215 else None,
216 query_dim=dim,
217 heads=num_attention_heads,
218 dim_head=attention_head_dim,
219 dropout=dropout,
220 bias=attention_bias,
221 upcast_attention=upcast_attention,
222 cross_frame_attention_mode=cross_frame_attention_mode,
223 temporal_position_encoding=temporal_position_encoding,
224 temporal_position_encoding_max_len=temporal_position_encoding_max_len,
225 )
226 )
227 norms.append(nn.LayerNorm(dim))
228
229 self.attention_blocks = nn.ModuleList(attention_blocks)
230 self.norms = nn.ModuleList(norms)
231
232 self.ff = FeedForward(dim, dropout=dropout, activation_fn=activation_fn)
233 self.ff_norm = nn.LayerNorm(dim)
234
235 def forward(
236 self,

Callers

nothing calls this directly

Calls 2

VersatileAttentionClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected