almangad commited on
Commit
8fdbc5b
·
verified ·
1 Parent(s): dc0fae1

create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
7
+ learner = from_pretrained_fastai(repo_id)
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="Escribe aquí el texto a clasificar..."),
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"],
20
+ ["i am feeling grouchy"]
21
+ ]
22
+ )
23
+
24
+ demo.launch(share=False)