Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|