Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,17 +10,14 @@ repo_id = "isboudja/Spam"
|
|
| 10 |
learner = from_pretrained_fastai(repo_id)
|
| 11 |
labels = learner.dls.vocab
|
| 12 |
|
| 13 |
-
# Define a function to make predictions
|
| 14 |
def predict(text):
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
probs = prediction[1:]
|
| 18 |
-
return {pred: float(probs[i]) for i, pred in enumerate(labels)}
|
| 19 |
|
| 20 |
-
# Create and launch the Gradio interface
|
| 21 |
gr.Interface(
|
| 22 |
fn=predict,
|
| 23 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
| 24 |
outputs=gr.outputs.Label(),
|
| 25 |
-
examples=["
|
| 26 |
).launch(share=False)
|
|
|
|
| 10 |
learner = from_pretrained_fastai(repo_id)
|
| 11 |
labels = learner.dls.vocab
|
| 12 |
|
|
|
|
| 13 |
def predict(text):
|
| 14 |
+
pred, pred_idx, probs = learner.predict(text)
|
| 15 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
# Create and launch the Gradio interface for text input
|
| 18 |
gr.Interface(
|
| 19 |
fn=predict,
|
| 20 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
| 21 |
outputs=gr.outputs.Label(),
|
| 22 |
+
examples=["WON a guaranteed £1000 cash"]
|
| 23 |
).launch(share=False)
|