almangad commited on
Commit
f04c868
·
verified ·
1 Parent(s): a2fa213
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -1,6 +1,6 @@
1
- from huggingface_hub import from_pretrained_fastai
2
  import gradio as gr
3
  from fastai.text.all import *
 
4
 
5
  repo_id = "almangad/entregable3"
6
 
@@ -8,13 +8,12 @@ learner = from_pretrained_fastai(repo_id)
8
  labels = learner.dls.vocab[1]
9
 
10
  def predict_text(texto):
11
- res = learner.predict(texto)
12
- probs = res[-1]
13
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
 
15
  demo = gr.Interface(
16
  fn=predict_text,
17
- inputs=gr.Textbox(lines=3, placeholder="Text here"),
18
  outputs=gr.Label(num_top_classes=6),
19
  examples=[
20
  ["im feeling quite sad and sorry for myself but ill snap out of it soon"],
@@ -22,4 +21,4 @@ demo = gr.Interface(
22
  ]
23
  )
24
 
25
- demo.launch(share=False)
 
 
1
  import gradio as gr
2
  from fastai.text.all import *
3
+ from huggingface_hub import from_pretrained_fastai
4
 
5
  repo_id = "almangad/entregable3"
6
 
 
8
  labels = learner.dls.vocab[1]
9
 
10
  def predict_text(texto):
11
+ pred, pred_idx, probs = learner.predict(texto)
 
12
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
 
14
  demo = gr.Interface(
15
  fn=predict_text,
16
+ inputs=gr.Textbox(lines=3, placeholder="Text here..."),
17
  outputs=gr.Label(num_top_classes=6),
18
  examples=[
19
  ["im feeling quite sad and sorry for myself but ill snap out of it soon"],
 
21
  ]
22
  )
23
 
24
+ demo.launch()