Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,21 +12,13 @@ labels = learner.dls.vocab
|
|
12 |
|
13 |
# Define a function to make predictions
|
14 |
def predict(text):
|
15 |
-
|
16 |
-
|
17 |
-
pred, pred_idx, probs = prediction[:3]
|
18 |
-
|
19 |
-
negative_label, positive_label = labels
|
20 |
-
|
21 |
-
return {
|
22 |
-
negative_label: float(probs[0]),
|
23 |
-
positive_label: float(probs[1])
|
24 |
-
}
|
25 |
|
26 |
# Create and launch the Gradio interface
|
27 |
gr.Interface(
|
28 |
fn=predict,
|
29 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
30 |
-
outputs=gr.outputs.Label(num_top_classes=
|
31 |
examples=["Hello, how are you?", "You won a prize! Click here to claim."]
|
32 |
).launch(share=False)
|
|
|
12 |
|
13 |
# Define a function to make predictions
|
14 |
def predict(text):
|
15 |
+
pred,pred_idx,probs = learner.predict(text)
|
16 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Create and launch the Gradio interface
|
19 |
gr.Interface(
|
20 |
fn=predict,
|
21 |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
22 |
+
outputs=gr.outputs.Label(num_top_classes=1),
|
23 |
examples=["Hello, how are you?", "You won a prize! Click here to claim."]
|
24 |
).launch(share=False)
|