| import gradio as gr |
| from gradio_client import Client, handle_file |
|
|
| def generate_video(image_path, prompt): |
| if image_path is None: |
| return None |
| |
| try: |
| |
| client = Client("ibuildproducts/wan22-i2v-v4-demo") |
| |
| |
| |
| job = client.submit( |
| input_image=handle_file(image_path), |
| prompt=prompt, |
| api_name="/predict" |
| ) |
| |
| |
| result = job.result() |
| |
| |
| return result |
| except Exception as e: |
| print(f"Error: {e}") |
| return None |
|
|
| |
| with gr.Blocks() as demo: |
| with gr.Row(): |
| with gr.Column(): |
| img_input = gr.Image(type="filepath") |
| prompt_input = gr.Textbox(label="Prompt", value="cinematic motion, high quality") |
| submit_btn = gr.Button("ساخت ویدیو") |
| with gr.Column(): |
| video_output = gr.Video() |
|
|
| submit_btn.click(generate_video, [img_input, prompt_input], video_output) |
|
|
| demo.launch() |
|
|