CogVideoXTransformer3DModel¶
A Diffusion Transformer model for 3D data from CogVideoX was introduced in CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer by Tsinghua University & ZhipuAI.
The model can be loaded with the following code snippet.
from mindone.diffusers import CogVideoXTransformer3DModel
vae = CogVideoXTransformer3DModel.from_pretrained("THUDM/CogVideoX-2b", subfolder="transformer", mindspore_dtype=mindspore.float16)
mindone.diffusers.models.transformers.cogvideox_transformer_3d.CogVideoXTransformer3DModel
¶
Bases: ModelMixin
, ConfigMixin
A Transformer model for video-like data in CogVideoX.
PARAMETER | DESCRIPTION |
---|---|
num_attention_heads |
The number of heads to use for multi-head attention.
TYPE:
|
attention_head_dim |
The number of channels in each head.
TYPE:
|
in_channels |
The number of channels in the input.
TYPE:
|
out_channels |
The number of channels in the output.
TYPE:
|
flip_sin_to_cos |
Whether to flip the sin to cos in the time embedding.
TYPE:
|
time_embed_dim |
Output dimension of timestep embeddings.
TYPE:
|
text_embed_dim |
Input dimension of text embeddings from the text encoder.
TYPE:
|
num_layers |
The number of layers of Transformer blocks to use.
TYPE:
|
dropout |
The dropout probability to use.
TYPE:
|
attention_bias |
Whether or not to use bias in the attention projection layers.
TYPE:
|
sample_width |
The width of the input latents.
TYPE:
|
sample_height |
The height of the input latents.
TYPE:
|
sample_frames |
The number of frames in the input latents. Note that this parameter was incorrectly initialized to 49 instead of 13 because CogVideoX processed 13 latent frames at once in its default and recommended settings, but cannot be changed to the correct value to ensure backwards compatibility. To create a transformer with K latent frames, the correct value to pass here would be: ((K - 1) * temporal_compression_ratio + 1).
TYPE:
|
patch_size |
The size of the patches to use in the patch embedding layer.
TYPE:
|
temporal_compression_ratio |
The compression ratio across the temporal dimension. See documentation for
TYPE:
|
max_text_seq_length |
The maximum sequence length of the input text embeddings.
TYPE:
|
activation_fn |
Activation function to use in feed-forward.
TYPE:
|
timestep_activation_fn |
Activation function to use when generating the timestep embeddings.
TYPE:
|
norm_elementwise_affine |
Whether or not to use elementwise affine in normalization layers.
TYPE:
|
norm_eps |
The epsilon value to use in normalization layers.
TYPE:
|
spatial_interpolation_scale |
Scaling factor to apply in 3D positional embeddings across spatial dimensions.
TYPE:
|
temporal_interpolation_scale |
Scaling factor to apply in 3D positional embeddings across temporal dimensions.
TYPE:
|
Source code in mindone/diffusers/models/transformers/cogvideox_transformer_3d.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
|
mindone.diffusers.models.transformers.cogvideox_transformer_3d.CogVideoXTransformer3DModel.attn_processors: Dict[str, AttentionProcessor]
property
¶
RETURNS | DESCRIPTION |
---|---|
Dict[str, AttentionProcessor]
|
|
Dict[str, AttentionProcessor]
|
indexed by its weight name. |
mindone.diffusers.models.transformers.cogvideox_transformer_3d.CogVideoXTransformer3DModel.fuse_qkv_projections()
¶
Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query, key, value) are fused. For cross-attention modules, key and value projection matrices are fused.
This API is 🧪 experimental.
Source code in mindone/diffusers/models/transformers/cogvideox_transformer_3d.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
mindone.diffusers.models.transformers.cogvideox_transformer_3d.CogVideoXTransformer3DModel.set_attn_processor(processor)
¶
Sets the attention processor to use to compute attention.
PARAMETER | DESCRIPTION |
---|---|
processor |
The instantiated processor class or a dictionary of processor classes that will be set as the processor
for all If
TYPE:
|
Source code in mindone/diffusers/models/transformers/cogvideox_transformer_3d.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
mindone.diffusers.models.transformers.cogvideox_transformer_3d.CogVideoXTransformer3DModel.unfuse_qkv_projections()
¶
Disables the fused QKV projection if enabled.
This API is 🧪 experimental.
Source code in mindone/diffusers/models/transformers/cogvideox_transformer_3d.py
401 402 403 404 405 406 407 408 409 410 411 412 |
|
mindone.diffusers.models.modeling_outputs.Transformer2DModelOutput
dataclass
¶
Bases: BaseOutput
The output of [Transformer2DModel
].
PARAMETER | DESCRIPTION |
---|---|
`(batch |
The hidden states output conditioned on the
TYPE:
|
Source code in mindone/diffusers/models/modeling_outputs.py
22 23 24 25 26 27 28 29 30 31 32 33 34 |
|