Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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("
|
10 |
|
11 |
kosmos2_result = kosmos2_client.predict(
|
12 |
-
image_in,
|
13 |
-
|
14 |
-
|
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}")
|