fffiloni commited on
Commit
0b71c1e
·
verified ·
1 Parent(s): 1742a42

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +51 -18
gradio_app.py CHANGED
@@ -1,24 +1,35 @@
1
- from huggingface_hub import InferenceClient
2
 
3
- client = InferenceClient(
4
- provider="fal-ai",
5
- api_key="",
6
- )
7
 
8
- # output is a PIL.Image object
9
- image = client.text_to_image(
10
- "Astronaut riding a horse",
11
- model="multimodalart/isometric-skeumorphic-3d-bnb",
12
- )
13
 
14
- from gradio_client import Client, handle_file
 
 
 
 
15
 
16
- client = Client("Lightricks/ltx-video-distilled")
17
- result = client.predict(
18
- prompt="The creature from the image starts to move",
 
 
 
 
 
 
 
 
 
 
 
19
  negative_prompt="worst quality, inconsistent motion, blurry, jittery, distorted",
20
- input_image_filepath=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
21
- input_video_filepath="Hello!!",
22
  height_ui=512,
23
  width_ui=704,
24
  mode="image-to-video",
@@ -29,5 +40,27 @@ result = client.predict(
29
  ui_guidance_scale=1,
30
  improve_texture_flag=True,
31
  api_name="/image_to_video"
32
- )
33
- print(result)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
 
3
+ def infer(text_prompt, action_prompt):
4
+ from huggingface_hub import InferenceClient
 
 
5
 
6
+ inf_client = InferenceClient(
7
+ provider="fal-ai"
8
+ )
 
 
9
 
10
+ # output is a PIL.Image object
11
+ image = inf_client.text_to_image(
12
+ text_prompt,
13
+ model="multimodalart/isometric-skeumorphic-3d-bnb",
14
+ )
15
 
16
+ import tempfile
17
+
18
+ # Create a temporary PNG file
19
+ with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp_file:
20
+ temp_image_path = tmp_file.name
21
+ image.save(temp_image_path, format="PNG")
22
+
23
+ print(f"✅ Image saved temporarily at: {temp_image_path}")
24
+
25
+ from gradio_client import Client, handle_file
26
+
27
+ gr_client = Client("Lightricks/ltx-video-distilled")
28
+ result = gr_client.predict(
29
+ prompt=action_prompt,
30
  negative_prompt="worst quality, inconsistent motion, blurry, jittery, distorted",
31
+ input_image_filepath=handle_file(temp_image_path),
32
+ input_video_filepath=None,
33
  height_ui=512,
34
  width_ui=704,
35
  mode="image-to-video",
 
40
  ui_guidance_scale=1,
41
  improve_texture_flag=True,
42
  api_name="/image_to_video"
43
+ )
44
+ print(result)
45
+
46
+ return temp_image_path, result
47
+
48
+ with gr.Blocks() as demo:
49
+
50
+ with gr.Column():
51
+
52
+ login = gr.LoginButton()
53
+
54
+ text_prompt = gr.Textbox(label="Icon label")
55
+ action_prompt = gr.Textbox(label="Action label")
56
+ submit_btn = gr.Button("Submit")
57
+ image_out = gr.Image()
58
+ video_out = gr.Video()
59
+
60
+ submit_btn.click(
61
+ fn = infer,
62
+ inputs = [text_prompt, action_prompt],
63
+ outputs = [image_out, video_out]
64
+ )
65
+
66
+ demo.launch(show_error=True)