enamezto commited on
Commit
047d5d6
·
verified ·
1 Parent(s): 2b41480

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import from_pretrained_fastai
2
+ from fastai.text.all import *
3
+ import gradio as gr
4
+
5
+ repo_id = "enamezto/MMLA"
6
+
7
+ learnerClass = from_pretrained_fastai(repo_id)
8
+ labels = [' acknowledge', ' advise', ' agree', ' agreement', ' anger', ' angry', ' answer', ' apologise', ' apology', ' arrange', ' ask for help', ' asking for opinions', ' backchannel', ' care', ' change', ' comfort', ' command', ' complain', ' confirm', ' criticize', ' disagreement', ' disgust', ' doubt', ' emphasize', ' excited', ' explain', ' fear', ' flaunt', ' frustrated', ' greet', ' greeting', ' happy', ' humorous', ' inform', ' introduce', ' invite', ' joke', ' joy', ' leave', ' negative', ' neutral', ' oppose', ' other', ' others', ' plan', ' positive', ' praise', ' prevent', ' question', ' reflection', ' refuse', ' sad', ' sadness', ' sarcastic', ' serious', ' sincere', ' statement-non-opinion', ' statement-opinion', ' surprise', ' sustain', ' taunt', ' thank', ' therapist_input', ' warn']
9
+
10
+
11
+ def predict(text):
12
+ pred, pred_idx, probs = learnerClass.predict(text)
13
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
+
15
+
16
+ gr.Interface(
17
+ fn=predict,
18
+ inputs=gr.Textbox(lines=3, placeholder="Escribe una frase cualquiera..."),
19
+ outputs=gr.Label(num_top_classes=3),
20
+ title="Clasificador de frases",
21
+ description="Introduce la frase"
22
+ ).launch()