isboudja commited on
Commit
2dda83f
·
verified ·
1 Parent(s): 1ce8540

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -11
app.py CHANGED
@@ -12,21 +12,13 @@ labels = learner.dls.vocab
12
 
13
  # Define a function to make predictions
14
  def predict(text):
15
- prediction = learner.predict(text)
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=2),
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)