Spaces:
Sleeping
Sleeping
first commit
Browse files- .gitignore +1 -0
- demo.py +26 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__pycache__/
|
demo.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Demo interface with Gradio."""
|
2 |
+
import gradio as gr
|
3 |
+
import requests
|
4 |
+
|
5 |
+
|
6 |
+
def greet(text: str):
|
7 |
+
"""
|
8 |
+
Send the text to the model and return the probabilities
|
9 |
+
"""
|
10 |
+
# url = 'http://127.0.0.1:8000/classify/'
|
11 |
+
url = 'https://modelapi-asxiavoigq-uc.a.run.app/classify/'
|
12 |
+
data = {'user_input': text}
|
13 |
+
response = requests.post(url, json=data, timeout=60)
|
14 |
+
data = response.json()
|
15 |
+
example = {i['label']: i['probability'] for i in data['probabilities']}
|
16 |
+
return example
|
17 |
+
|
18 |
+
|
19 |
+
demo = gr.Interface(
|
20 |
+
fn=greet,
|
21 |
+
inputs=gr.Text(label='Human entry'),
|
22 |
+
outputs=gr.Label(num_top_classes=3, label='Probabilities'),
|
23 |
+
allow_flagging='never'
|
24 |
+
)
|
25 |
+
|
26 |
+
demo.launch(share=True)
|