import gradio as gr
import os
import sys
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
model = None # Placeholder for model
def gradio_main_fn(prompt, 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,
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=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, 320, 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=0)
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")
def setup_model_progress(lora_model, lora_rank):
global model
# Disable buttons and show loading indicator
yield (gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False), "Loading model...")
model = setup_model(lora_model, lora_rank) # Ensure you pass the necessary parameters to the setup_model function
# Enable buttons after loading and update indicator
yield (gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True), "Model loaded successfully")
css = """
.centered {
display: flex;
justify-content: center;
}
"""
with gr.Blocks(css=css) as demo:
with gr.Row():
with gr.Column():
gr.HTML(
"""