fffiloni commited on
Commit
8af42ca
1 Parent(s): f508df4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import gradio as gr
 
2
  import numpy as np
3
  import tempfile
4
  import imageio
@@ -13,10 +14,19 @@ pipe.enable_model_cpu_offload()
13
 
14
 
15
  def create_image_caption(image_init):
16
- caption = gr.load(name="spaces/fffiloni/CoCa-clone")
17
- cap = caption(image_init, "Nucleus sampling", 1.2, 0.5, 5, 20, fn_index=0)
18
- print("cap: " + cap)
19
- return cap
 
 
 
 
 
 
 
 
 
20
 
21
  def export_to_video(frames: np.ndarray, fps: int) -> str:
22
  frames = np.clip((frames * 255), 0, 255).astype(np.uint8)
 
1
  import gradio as gr
2
+ from gradio_client import Client, handle_file
3
  import numpy as np
4
  import tempfile
5
  import imageio
 
14
 
15
 
16
  def create_image_caption(image_init):
17
+ client = Client("fffiloni/CoCa-clone")
18
+ result = client.predict(
19
+ image=handle_file(image_init),
20
+ decoding_method="Nucleus sampling",
21
+ rep_penalty=1.2,
22
+ top_p=0.5,
23
+ min_seq_len=5,
24
+ seq_len=20,
25
+ api_name="/inference_caption"
26
+ )
27
+ print(f"cap: {result}")
28
+
29
+ return result
30
 
31
  def export_to_video(frames: np.ndarray, fps: int) -> str:
32
  frames = np.clip((frames * 255), 0, 255).astype(np.uint8)