Krish623 commited on
Commit
16e269b
·
verified ·
1 Parent(s): f0dc67d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -12,5 +12,13 @@ def predict(text):
12
  best = max(scores, key=lambda x: x["score"])
13
  return {"label": best["label"], "score": best["score"]}
14
 
15
- demo = gr.Interface(fn=predict, inputs="text", outputs="json", title="Sentiment Analysis")
 
 
 
 
 
 
 
 
16
  demo.launch()
 
12
  best = max(scores, key=lambda x: x["score"])
13
  return {"label": best["label"], "score": best["score"]}
14
 
15
+ # USE BLOCKS (IMPORTANT)
16
+ with gr.Blocks() as demo:
17
+ inp = gr.Textbox(label="Enter text")
18
+ out = gr.JSON()
19
+ btn = gr.Button("Predict")
20
+
21
+ # 👇 THIS LINE FIXES EVERYTHING
22
+ btn.click(fn=predict, inputs=inp, outputs=out, api_name="/predict")
23
+
24
  demo.launch()