text-to-video / app.py
NihalGazi's picture
Update app.py
ee0797c verified
raw
history blame
2.44 kB
import gradio as gr
from gradio_client import Client, handle_file
def generate_video(input_image, prompt, negative_prompt, diffusion_step, height, width, scfg_scale, use_dctinit, dct_coefficients, noise_level, motion_bucket_id, seed):
client = Client("maxin-cn/Cinemo")
try:
result = client.predict(
input_image=handle_file(input_image),
prompt=prompt,
negative_prompt=negative_prompt,
diffusion_step=diffusion_step,
height=height,
width=width,
scfg_scale=scfg_scale,
use_dctinit=use_dctinit,
dct_coefficients=dct_coefficients,
noise_level=noise_level,
motion_bucket_id=motion_bucket_id,
seed=seed,
api_name="/gen_video"
)
print("API Response:", result)
return result
except Exception as e:
return f"Error: {str(e)}"
# Define the Gradio interface
with gr.Blocks() as demo:
with gr.Row():
input_image = gr.Image(label="Input Image", type="filepath")
with gr.Column():
prompt = gr.Textbox(label="Prompt", placeholder="Enter prompt here...")
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter negative prompt here...")
diffusion_step = gr.Slider(minimum=1, maximum=100, value=50, label="Diffusion Steps")
height = gr.Slider(minimum=128, maximum=1024, value=320, label="Height")
width = gr.Slider(minimum=128, maximum=1024, value=512, label="Width")
scfg_scale = gr.Slider(minimum=1.0, maximum=20.0, value=7.5, label="CFG Scale")
use_dctinit = gr.Checkbox(value=True, label="Enable DCTInit")
dct_coefficients = gr.Slider(minimum=0.0, maximum=1.0, value=0.23, label="DCT Coefficients")
noise_level = gr.Slider(minimum=0, maximum=1000, value=985, label="Noise Level")
motion_bucket_id = gr.Slider(minimum=1, maximum=100, value=10, label="Motion Intensity")
seed = gr.Slider(minimum=1, maximum=10000, value=100, label="Seed")
generate_btn = gr.Button("Generate Video")
output_video = gr.Video(label="Generated Video")
generate_btn.click(generate_video, inputs=[input_image, prompt, negative_prompt, diffusion_step, height, width, scfg_scale, use_dctinit, dct_coefficients, noise_level, motion_bucket_id, seed], outputs=output_video)
# Launch the app with verbose error reporting
demo.launch(show_error=True)