import gradio as gr import os import spaces import sys from copy import deepcopy sys.path.append('./VADER-VideoCrafter/scripts/main') sys.path.append('./VADER-VideoCrafter/scripts') sys.path.append('./VADER-VideoCrafter') from train_t2v_lora import main_fn, setup_model examples = [ ["A fairy tends to enchanted, glowing flowers.", 'huggingface-hps-aesthetic', 8, 400, 384, 512, 12.0, 25, 1.0, 24, 10], ["A cat playing an electric guitar in a loft with industrial-style decor and soft, multicolored lights.", 'huggingface-hps-aesthetic', 8, 206, 384, 512, 12.0, 25, 1.0, 24, 10], ["A raccoon playing a guitar under a blossoming cherry tree.", 'huggingface-hps-aesthetic', 8, 204, 384, 512, 12.0, 25, 1.0, 24, 10], ["A mermaid with flowing hair and a shimmering tail discovers a hidden underwater kingdom adorned with coral palaces, glowing pearls, and schools of colorful fish, encountering both wonders and dangers along the way.", "huggingface-pickscore", 16, 205, 384, 512, 12.0, 25, 1.0, 24, 10], ["A talking bird with shimmering feathers and a melodious voice leads an adventure to find a legendary treasure, guiding through enchanted forests, ancient ruins, and mystical challenges.", "huggingface-pickscore", 16, 204, 384, 512, 12.0, 25, 1.0, 24, 10] ] model = setup_model() @spaces.GPU(duration=120) def gradio_main_fn(prompt, lora_model, lora_rank, seed, height, width, unconditional_guidance_scale, ddim_steps, ddim_eta, frames, savefps): global model if model is None: return "Model is not loaded. Please load the model first." video_path = main_fn(prompt=prompt, lora_model=lora_model, lora_rank=int(lora_rank), seed=int(seed), height=int(height), width=int(width), unconditional_guidance_scale=float(unconditional_guidance_scale), ddim_steps=int(ddim_steps), ddim_eta=float(ddim_eta), frames=int(frames), savefps=int(savefps), model=deepcopy(model)) return video_path def reset_fn(): return ("A mermaid with flowing hair and a shimmering tail discovers a hidden underwater kingdom adorned with coral palaces, glowing pearls, and schools of colorful fish, encountering both wonders and dangers along the way.", 200, 384, 512, 12.0, 25, 1.0, 24, 16, 10, "huggingface-pickscore") def update_lora_rank(lora_model): if lora_model == "huggingface-pickscore": return gr.update(value=16) elif lora_model == "huggingface-hps-aesthetic": return gr.update(value=8) else: # "Base Model" return gr.update(value=8) def update_dropdown(lora_rank): if lora_rank == 16: return gr.update(value="huggingface-pickscore") elif lora_rank == 8: return gr.update(value="huggingface-hps-aesthetic") else: # 0 return gr.update(value="Base Model") custom_css = """ #centered { display: flex; justify-content: center; width: 60%; margin: 0 auto; } .column-centered { display: flex; flex-direction: column; align-items: center; width: 60%; } #image-upload { flex-grow: 1; } #params .tabs { display: flex; flex-direction: column; flex-grow: 1; } #params .tabitem[style="display: block;"] { flex-grow: 1; display: flex !important; } #params .gap { flex-grow: 1; } #params .form { flex-grow: 1 !important; } #params .form > :last-child{ flex-grow: 1; } """ with gr.Blocks(css=custom_css) as demo: with gr.Row(): with gr.Column(): gr.HTML( """