|
|
import gradio as gr |
|
|
import spaces |
|
|
import torch |
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@spaces.GPU |
|
|
def run_stylization(input_video_path, prompt, noise_scale, shift_gamma, steps, guidance_scale, seed): |
|
|
""" |
|
|
这里是实际推理逻辑的占位符。 |
|
|
""" |
|
|
if not input_video_path: |
|
|
return None |
|
|
|
|
|
print("========== Inference Start ==========") |
|
|
print(f"Video Path: {input_video_path}") |
|
|
print(f"Prompt: {prompt}") |
|
|
print(f"Params: Noise={noise_scale}, Gamma={shift_gamma}, Steps={steps}, CFG={guidance_scale}, Seed={seed}") |
|
|
|
|
|
|
|
|
return input_video_path |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
with gr.Column(elem_id="col-container"): |
|
|
gr.Markdown("# 🎥 ViBT Video Stylization Interface") |
|
|
gr.Markdown("上传视频并设置风格化参数。") |
|
|
|
|
|
with gr.Row(): |
|
|
|
|
|
with gr.Column(): |
|
|
|
|
|
input_video = gr.Video(label="Source Video", sources=["upload"]) |
|
|
|
|
|
|
|
|
prompt_input = gr.Textbox( |
|
|
label="Style Prompt", |
|
|
placeholder="e.g., Van Gogh style, cyberpunk city...", |
|
|
value="Oil painting style, vivid colors" |
|
|
) |
|
|
|
|
|
|
|
|
with gr.Accordion("Advanced Settings", open=True): |
|
|
with gr.Row(): |
|
|
noise_scale = gr.Slider( |
|
|
label="Noise Scale", minimum=0.0, maximum=2.0, step=0.1, value=1.0, |
|
|
info="Controls how much noise is added." |
|
|
) |
|
|
shift_gamma = gr.Slider( |
|
|
label="Shift Gamma", minimum=1.0, maximum=10.0, step=0.5, value=5.0, |
|
|
info="Scheduler parameter." |
|
|
) |
|
|
|
|
|
with gr.Row(): |
|
|
num_steps = gr.Slider( |
|
|
label="Inference Steps", minimum=10, maximum=50, step=1, value=28, |
|
|
info="More steps = higher quality but slower." |
|
|
) |
|
|
guidance_scale = gr.Slider( |
|
|
label="Guidance Scale (CFG)", minimum=1.0, maximum=20.0, step=0.5, value=1.5, |
|
|
info="How closely to follow the prompt." |
|
|
) |
|
|
|
|
|
seed = gr.Number(label="Seed", value=42, precision=0) |
|
|
|
|
|
|
|
|
run_btn = gr.Button("Generate Video", variant="primary") |
|
|
|
|
|
|
|
|
with gr.Column(): |
|
|
output_video = gr.Video(label="Stylized Result", interactive=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
run_btn.click( |
|
|
fn=run_stylization, |
|
|
inputs=[ |
|
|
input_video, |
|
|
prompt_input, |
|
|
noise_scale, |
|
|
shift_gamma, |
|
|
num_steps, |
|
|
guidance_scale, |
|
|
seed |
|
|
], |
|
|
outputs=[output_video] |
|
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch() |