Spaces:
Sleeping
Sleeping
Commit
·
b5c4b5f
1
Parent(s):
f64d0f8
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import from_pretrained_fastai
|
2 |
+
import gradio as gr
|
3 |
+
from fastai.vision.all import *
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"
|
8 |
+
repo_id = "joelmateo14/peliculas"
|
9 |
+
|
10 |
+
learner = from_pretrained_fastai(repo_id)
|
11 |
+
labels = learner.dls.vocab
|
12 |
+
|
13 |
+
# Definimos una función que se encarga de llevar a cabo las predicciones
|
14 |
+
def predict(text):
|
15 |
+
pred,pred_idx,probs = learner.predict(text)
|
16 |
+
if (pred=="0"):
|
17 |
+
return neg
|
18 |
+
elif (pred=="1"):
|
19 |
+
return pos
|
20 |
+
else:
|
21 |
+
return error
|
22 |
+
|
23 |
+
# Creamos la interfaz y la lanzamos.
|
24 |
+
gr.Interface(fn=predict, inputs="text", outputs="label",examples=["i would not watch it again, it is amazing one of my favorites"]).launch()
|