image_encoding
¶
Image and video encoding stages for diffusion pipelines.
This module contains implementations of encoding stages for diffusion pipelines: - ImageEncodingStage: Encodes images using image encoders (e.g., CLIP) - RefImageEncodingStage: Encodes reference image for Wan2.1 control pipeline - ImageVAEEncodingStage: Encodes images to latent space using VAE for I2V generation - VideoVAEEncodingStage: Encodes videos to latent space using VAE for V2V and control tasks
Classes¶
fastvideo.pipelines.stages.image_encoding.ImageEncodingStage
¶
Bases: PipelineStage
Stage for encoding image prompts into embeddings for diffusion models.
This stage handles the encoding of image prompts into the embedding space expected by the diffusion model.
Initialize the prompt encoding stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable_logging
|
Whether to enable logging for this stage. |
required | |
is_secondary
|
Whether this is a secondary image encoder. |
required |
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.ImageEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded prompt embeddings. |
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.ImageEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify image encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.ImageEncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify image encoding stage outputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.ImageVAEEncodingStage
¶
Bases: PipelineStage
Stage for encoding image pixel representations into latent space.
This stage handles the encoding of image pixel representations into the final input format (e.g., latents) for image-to-video generation.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.ImageVAEEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode pixel representations into latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded outputs. |
Source code in fastvideo/pipelines/stages/image_encoding.py
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 | |
fastvideo.pipelines.stages.image_encoding.ImageVAEEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.ImageVAEEncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage outputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.RefImageEncodingStage
¶
Bases: ImageEncodingStage
Stage for encoding reference image prompts into embeddings for Wan2.1 Control models.
This stage extends ImageEncodingStage with specialized preprocessing for reference images.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.RefImageEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded prompt embeddings. |
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.VideoVAEEncodingStage
¶
Bases: ImageVAEEncodingStage
Stage for encoding video pixel representations into latent space.
This stage handles the encoding of video pixel representations for video-to-video generation and control. Inherits from ImageVAEEncodingStage to reuse common functionality.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.VideoVAEEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode video pixel representations into latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded outputs. |
Source code in fastvideo/pipelines/stages/image_encoding.py
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 | |
fastvideo.pipelines.stages.image_encoding.VideoVAEEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify video encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.VideoVAEEncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify video encoding stage outputs.