isboudja commited on
Commit
070bec4
·
verified ·
1 Parent(s): 6100e60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
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
- prediction = learner.predict(text)
16
- pred = prediction[0]
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=["Hello, how are you?", "You won a prize! Click here to claim."]
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)