osrandez commited on
Commit
7bee398
1 Parent(s): 32857b0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import from_pretrained_fastai
2
+ import gradio as gr
3
+ from fastai.vision.all import *
4
+
5
+ repo_id = "osrandez/sst2"
6
+
7
+ labels = ['mala','buena']
8
+ learner = from_pretrained_fastai(repo_id)
9
+
10
+ def predict(text):
11
+ pred,pred_idx,probs = learner.predict(text)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=gr.outputs.Label(num_top_classes=2)).launch(share=False,debug=True)