Spaces:
Build error
Build error
File size: 1,166 Bytes
a2887cd 262c90c a2887cd 262c90c |
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import gradio as gr
from model import inference
def predict(sentence: str):
model_response = inference({"sentence": sentence})
prob = model_response["answer"]
df = {
"1": float(prob[1][0][2]),
"0": float(prob[1][0][1]),
"-1": float(prob[1][0][0]),
"Communication": float(prob[0][0][0]),
"Quality": float(prob[0][0][1]),
"Price": float(prob[0][0][2]),
"Safety": float(prob[0][0][3]),
}
return (
df["1"],
df["0"],
df["-1"],
df["Communication"],
df["Quality"],
df["Price"],
df["Safety"],
)
if __name__ == "__main__":
print("App started")
gr.Interface(
fn=predict,
title="Try it yourself!",
inputs=gr.Textbox(lines=3, placeholder="Sentence here..."),
outputs=[
gr.Number(0.0, label="1"),
gr.Number(0.0, label="0"),
gr.Number(0.0, label="-1"),
gr.Number(0.0, label="Communication"),
gr.Number(0.0, label="Quality"),
gr.Number(0.0, label="Price"),
gr.Number(0.0, label="Safety"),
],
).launch()
|