File size: 676 Bytes
8776261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
845657c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Demo interface with Gradio."""
import gradio as gr
import requests


def greet(text: str):
    """
    Send the text to the model and return the probabilities
    """
    # url = 'http://127.0.0.1:8000/classify/'
    url = 'https://modelapi-asxiavoigq-uc.a.run.app/classify/'
    data = {'user_input': text}
    response = requests.post(url, json=data, timeout=60)
    data = response.json()
    example = {i['label']: i['probability'] for i in data['probabilities']}
    return example


demo = gr.Interface(
    fn=greet,
    inputs=gr.Text(label='Human entry'),
    outputs=gr.Label(num_top_classes=3, label='Probabilities'),
    allow_flagging='never'
)

demo.launch()