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.
65 lines
2.5 KiB
Python
65 lines
2.5 KiB
Python
from fastvideo import VideoGenerator
|
|
from fastvideo.api import (
|
|
EngineConfig, GenerationRequest, GeneratorConfig, InputConfig, OffloadConfig, OutputConfig, SamplingConfig,
|
|
)
|
|
from fastvideo.models.dits.lingbotworld.cam_utils import prepare_camera_embedding
|
|
|
|
OUTPUT_PATH = "video_samples_lingbotworld"
|
|
def main():
|
|
# FastVideo will automatically use the optimal default arguments for the
|
|
# model.
|
|
# If a local path is provided, FastVideo will make a best effort
|
|
# attempt to identify the optimal arguments.
|
|
generator = VideoGenerator.from_config(
|
|
GeneratorConfig(
|
|
model_path="FastVideo/LingBot-World-Base-Cam-Diffusers",
|
|
engine=EngineConfig(
|
|
# FastVideo will automatically handle distributed setup
|
|
num_gpus=1,
|
|
use_fsdp_inference=False, # set to True if GPU is out of memory
|
|
offload=OffloadConfig(
|
|
dit=True, # DiT need to be offloaded for MoE
|
|
vae=False,
|
|
text_encoder=True,
|
|
# Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
|
|
pin_cpu_memory=True,
|
|
),
|
|
),
|
|
)
|
|
)
|
|
|
|
num_frames = 81
|
|
prompt = "The video presents a soaring journey through a fantasy jungle. The wind whips past the rider's blue hands gripping the reins, causing the leather straps to vibrate. The ancient gothic castle approaches steadily, its stone details becoming clearer against the backdrop of floating islands and distant waterfalls."
|
|
image_path = "https://raw.githubusercontent.com/Robbyant/lingbot-world/main/examples/00/image.jpg"
|
|
action_path = "examples/inference/basic/lingbotworld_examples/00"
|
|
c2ws_plucker_emb, num_frames = prepare_camera_embedding(
|
|
action_path=action_path,
|
|
num_frames=num_frames,
|
|
height=480,
|
|
width=832,
|
|
spatial_scale=8,
|
|
)
|
|
|
|
generator.generate(
|
|
GenerationRequest(
|
|
prompt=prompt,
|
|
inputs=InputConfig(
|
|
image_path=image_path,
|
|
c2ws_plucker_emb=c2ws_plucker_emb,
|
|
),
|
|
sampling=SamplingConfig(
|
|
num_frames=num_frames,
|
|
height=480,
|
|
width=832,
|
|
),
|
|
output=OutputConfig(
|
|
output_path=OUTPUT_PATH,
|
|
save_video=True,
|
|
),
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|