Spaces:
Sleeping
Sleeping
| 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() |