fffiloni commited on
Commit
697bfd1
1 Parent(s): ac1b8dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,17 +1,20 @@
1
  import gradio as gr
 
2
  import spaces
3
  import json
4
  import re
5
- from gradio_client import Client
 
 
6
 
7
 
8
  def get_caption_from_kosmos(image_in):
9
- kosmos2_client = Client("https://ydshieh-kosmos-2.hf.space/")
10
 
11
  kosmos2_result = kosmos2_client.predict(
12
- image_in, # str (filepath or URL to image) in 'Test Image' Image component
13
- "Detailed", # str in 'Description Type' Radio component
14
- fn_index=4
15
  )
16
 
17
  print(f"KOSMOS2 RETURNS: {kosmos2_result}")
 
1
  import gradio as gr
2
+ import os
3
  import spaces
4
  import json
5
  import re
6
+ from gradio_client import Client, handle_file
7
+
8
+ kosmos2_token = os.environ.get("KOSMOS2_TOKEN")
9
 
10
 
11
  def get_caption_from_kosmos(image_in):
12
+ kosmos2_client = Client("fffiloni/Kosmos-2-API", hf_token=kosmos2_token)
13
 
14
  kosmos2_result = kosmos2_client.predict(
15
+ image_input=handle_file(image_in),
16
+ text_input="Detailed",
17
+ api_name="/generate_predictions"
18
  )
19
 
20
  print(f"KOSMOS2 RETURNS: {kosmos2_result}")