diff --git a/examples/inference/gradio/gradio_frontend.py b/examples/inference/gradio/gradio_frontend.py index 24b704bbf..880d94be4 100644 --- a/examples/inference/gradio/gradio_frontend.py +++ b/examples/inference/gradio/gradio_frontend.py @@ -19,11 +19,11 @@ from fastvideo.configs.sample.base import SamplingParam # Map clean model names to full paths MODEL_PATH_MAPPING = { "FastWan2.1-T2V-1.3B": "FastVideo/FastWan2.1-T2V-1.3B-Diffusers", - "FastWan2.1-T2V-14B": "FastVideo/FastWan2.1-T2V-14B-Diffusers", + # "FastWan2.1-T2V-14B": "FastVideo/FastWan2.1-T2V-14B-Diffusers", "FastWan2.2-TI2V-5B": "FastVideo/FastWan2.2-TI2V-5B-Diffusers", - "Wan2.1-T2V-1.3B": "Wan-AI/Wan2.1-T2V-1.3B-Diffusers", - "Wan2.1-T2V-14B": "Wan-AI/Wan2.1-T2V-14B-Diffusers", - "Wan2.2-TI2V-5B": "Wan-AI/Wan2.2-TI2V-5B-Diffusers" + # "Wan2.1-T2V-1.3B": "Wan-AI/Wan2.1-T2V-1.3B-Diffusers", + # "Wan2.1-T2V-14B": "Wan-AI/Wan2.1-T2V-14B-Diffusers", + # "Wan2.2-TI2V-5B": "Wan-AI/Wan2.2-TI2V-5B-Diffusers" } @@ -383,6 +383,9 @@ def create_gradio_interface(backend_url: str, default_params: dict[str, Sampling model_path = model_selection_value.split(" (")[0] if model_selection_value else None if model_path and model_path in default_params: params = default_params[model_path] + if "1.3b" in model_path.lower(): + params.num_frames = 61 + return { 'height': params.height, 'width': params.width, @@ -412,7 +415,7 @@ def create_gradio_interface(backend_url: str, default_params: dict[str, Sampling gr.HTML("""

Make Video Generation Go Blurrrrrrr

-

Twitter | Code | Blog | Docs

+

Twitter | Code | Blog | Docs

""") @@ -421,7 +424,7 @@ def create_gradio_interface(backend_url: str, default_params: dict[str, Sampling gr.HTML("""

- It features a clean, consistent API that works across popular video models, making it easier for developers to author new models and incorporate system- or kernel-level optimizations. With FastVideo's optimizations, you can achieve more than 3x inference improvement compared to other systems. + FastVideo is an inference and post-training framework for diffusion models. It features an end-to-end unified pipeline for accelerating diffusion models, starting from data preprocessing to model training, finetuning, distillation, and inference. FastVideo is designed to be modular and extensible, allowing users to easily add new optimizations and techniques. Whether it is training-free optimizations or post-training optimizations, FastVideo has you covered.

""") @@ -445,8 +448,8 @@ def create_gradio_interface(backend_url: str, default_params: dict[str, Sampling choices=[ "FastWan2.1-T2V-1.3B", "FastWan2.2-TI2V-5B", - "Wan2.1-T2V-1.3B", - "Wan2.2-TI2V-5B", + # "Wan2.1-T2V-1.3B", + # "Wan2.2-TI2V-5B", # "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers (Image-to-Video)" # I2V functionality commented out ], value="FastWan2.1-T2V-1.3B", @@ -492,57 +495,57 @@ def create_gradio_interface(backend_url: str, default_params: dict[str, Sampling with gr.Column(scale=1, elem_classes="advanced-options-column"): with gr.Group(): gr.HTML("
Advanced Options
") - with gr.Row(): - height = gr.Slider( - label="Height", - minimum=256, - maximum=1280, - step=32, - value=initial_values['height'], - ) - width = gr.Slider( - label="Width", - minimum=256, - maximum=1280, - step=32, - value=initial_values['width'] - ) - - with gr.Row(): - num_frames = gr.Slider( - label="Number of Frames", - minimum=16, - maximum=121, - step=16, - value=initial_values['num_frames'], - ) - guidance_scale = gr.Slider( - label="Guidance Scale", - minimum=1, - maximum=12, - value=initial_values['guidance_scale'], - ) - - with gr.Row(): - use_negative_prompt = gr.Checkbox( - label="Use negative prompt", value=False) - negative_prompt = gr.Text( - label="Negative prompt", - max_lines=3, - lines=3, - placeholder="Enter a negative prompt", - visible=False, - ) + with gr.Row(): + height = gr.Slider( + label="Height", + minimum=256, + maximum=1280, + step=32, + value=initial_values['height'], + ) + width = gr.Slider( + label="Width", + minimum=256, + maximum=1280, + step=32, + value=initial_values['width'] + ) + + with gr.Row(): + num_frames = gr.Slider( + label="Number of Frames", + minimum=16, + maximum=121, + step=16, + value=initial_values['num_frames'], + ) + guidance_scale = gr.Slider( + label="Guidance Scale", + minimum=1, + maximum=12, + value=initial_values['guidance_scale'], + ) + + with gr.Row(): + use_negative_prompt = gr.Checkbox( + label="Use negative prompt", value=False) + negative_prompt = gr.Text( + label="Negative prompt", + max_lines=3, + lines=3, + placeholder="Enter a negative prompt", + visible=False, + ) - seed = gr.Slider( - label="Seed", - minimum=0, - maximum=1000000, - step=1, - value=initial_values['seed'], - ) - randomize_seed = gr.Checkbox(label="Randomize seed", value=False) - seed_output = gr.Number(label="Used Seed") + seed = gr.Slider( + label="Seed", + minimum=0, + maximum=1000000, + step=1, + value=initial_values['seed'], + ) + randomize_seed = gr.Checkbox(label="Randomize seed", value=False) + seed_output = gr.Number(label="Used Seed") # Right column - Video result with gr.Column(scale=1, elem_classes="video-column"): @@ -706,7 +709,7 @@ def create_gradio_interface(backend_url: str, default_params: dict[str, Sampling # Disclaimer text gr.HTML("""
-

The compute for this demo is generously provided by GMI Cloud. Note that this demo is meant to showcase FastWan2.1's quality and that under a large number of requests, generation speed may be affected.

+

The compute for this demo is generously provided by GMI Cloud. Note that this demo is meant to showcase FastWan's quality and that under a large number of requests, generation speed may be affected.

""") @@ -874,7 +877,7 @@ def main(): # print(f"I2V Model: {args.i2v_model_path}") # I2V functionality commented out # Use FastAPI to serve custom HTML with proper Open Graph metadata - from fastapi import FastAPI + from fastapi import FastAPI, Request from fastapi.responses import HTMLResponse, FileResponse import uvicorn import os @@ -883,39 +886,62 @@ def main(): @app.get("/logo.png") async def get_logo(): - return FileResponse("fastvideo-logos/main/png/full.png", media_type="image/png") + from fastapi import Response + return FileResponse( + "fastvideo-logos/main/png/full.png", + media_type="image/png", + headers={ + "Cache-Control": "public, max-age=3600", + "Access-Control-Allow-Origin": "*" + } + ) @app.get("/", response_class=HTMLResponse) - def index(): - return """ + def index(request: Request): + # Get the current host for dynamic URLs + base_url = str(request.base_url).rstrip('/') + return f""" - - - - - - - - - + + FastWan + + + + + + + + + + + + + + + + + + + + diff --git a/examples/inference/gradio/ray_serve_backend.py b/examples/inference/gradio/ray_serve_backend.py index 60c38d697..21f4a1e30 100644 --- a/examples/inference/gradio/ray_serve_backend.py +++ b/examples/inference/gradio/ray_serve_backend.py @@ -18,14 +18,10 @@ from slowapi.errors import RateLimitExceeded import imageio from ray.serve.handle import DeploymentHandle -NUM_GPUS = 8 +NUM_GPUS = 16 SUPPORTED_MODELS = [ "FastVideo/FastWan2.1-T2V-1.3B-Diffusers", - "FastVideo/FastWan2.1-T2V-14B-Diffusers", "FastVideo/FastWan2.2-TI2V-5B-Diffusers", - "Wan-AI/Wan2.1-T2V-1.3B-Diffusers", - "Wan-AI/Wan2.1-T2V-14B-Diffusers", - "Wan-AI/Wan2.2-TI2V-5B-Diffusers", ] @@ -109,10 +105,10 @@ class T2VModelDeployment: # time.sleep(5) # Ensure correct attention backend for FastVideo - if "FastVideo" in self.model_path: - os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "VIDEO_SPARSE_ATTN" - else: + if "5b" in self.model_path.lower(): os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "FLASH_ATTN" + else: + os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "VIDEO_SPARSE_ATTN" os.environ["FASTVIDEO_STAGE_LOGGING"] = "1" # Lazy import to keep the deployment import-safe on head node diff --git a/examples/inference/gradio/start.sh b/examples/inference/gradio/start.sh index 7d026acf6..1f5ae540f 100644 --- a/examples/inference/gradio/start.sh +++ b/examples/inference/gradio/start.sh @@ -1,3 +1,3 @@ python examples/inference/gradio/start_ray_serve_app.py \ ---t2v_model_paths "FastVideo/FastWan2.1-T2V-1.3B-Diffusers,FastVideo/FastWan2.2-TI2V-5B-Diffusers,Wan-AI/Wan2.1-T2V-1.3B-Diffusers,Wan-AI/Wan2.2-TI2V-5B-Diffusers" \ ---t2v_model_replicas "2,2,2,2" \ No newline at end of file +--t2v_model_paths "FastVideo/FastWan2.1-T2V-1.3B-Diffusers,FastVideo/FastWan2.2-TI2V-5B-Diffusers" \ +--t2v_model_replicas "8,8" \ No newline at end of file