File size: 943 Bytes
bf568ab
789532a
bf568ab
789532a
 
 
 
 
 
 
 
bf568ab
a7feda8
bf568ab
 
 
 
789532a
bf568ab
 
 
a7feda8
bf568ab
a7feda8
 
789532a
bf568ab
a7feda8
bf568ab
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
from gradio_client import Client, handle_file

def text_to_image(client, prompt, image, duration):
    result = client.predict(
		prompt=prompt,
		input_image_filepath=handle_file(image),
		duration_ui=duration,
		api_name="/generate_video"
    )
    return result


def set_client_for_session(request: gr.Request):
    x_ip_token = request.headers['x-ip-token']

    # The "gradio/text-to-image" space is a ZeroGPU space
    return Client("KingNish/ltx-video-distilled", headers={"X-IP-Token": x_ip_token})

with gr.Blocks() as demo:
    client = gr.State()
    image = gr.Image(type="filepath")
    prompt = gr.Textbox(max_lines=1)
    duration = gr.Slider(minimum=1, maximum=8, step=1, interactive=True)
    submit_button = gr.Button("Submit")
    output = gr.Video()

    submit_button.click(text_to_image, [client, prompt, image, duration], [output])

    demo.load(set_client_for_session, None, client)

demo.launch()