Move all examples/inference and scripts off the legacy
VideoGenerator.from_pretrained(model, **kwargs) +
generate_video(prompt, **kwargs) surface onto the typed
from_config(GeneratorConfig(...)) + generate(GenerationRequest(...))
convention, including the Kandinsky-5 and DreamX-World examples added
on main after the original migration. git-mv api/compat.py to
api/translation.py ('compat' implied a temporary shim; the forward
translation is its honest permanent role) and repoint all importers,
tests, and doc links.
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
import os
|
|
|
|
# Set SLA attention backend BEFORE fastvideo imports
|
|
os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "SLA_ATTN"
|
|
|
|
from fastvideo import VideoGenerator
|
|
from fastvideo.api import (
|
|
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig,
|
|
OutputConfig, SamplingConfig,
|
|
)
|
|
|
|
# Use local model path
|
|
MODEL_PATH = "loayrashid/TurboWan2.2-I2V-A14B-Diffusers"
|
|
OUTPUT_PATH = "video_samples_turbodiffusion_i2v"
|
|
|
|
|
|
def main() -> None:
|
|
# TurboDiffusion I2V: 1-4 step image-to-video generation
|
|
generator = VideoGenerator.from_config(
|
|
GeneratorConfig(
|
|
model_path=MODEL_PATH,
|
|
engine=EngineConfig(num_gpus=2),
|
|
)
|
|
)
|
|
|
|
# Example prompt and image for I2V
|
|
prompt = ("Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside.")
|
|
|
|
# Use an example image path
|
|
image_path = "https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/wan_i2v_input.JPG"
|
|
|
|
|
|
video = generator.generate(
|
|
GenerationRequest(
|
|
prompt=prompt,
|
|
inputs=InputConfig(image_path=image_path),
|
|
sampling=SamplingConfig(seed=42),
|
|
output=OutputConfig(output_path=OUTPUT_PATH, save_video=True),
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|