Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from fastai.text.all import *
|
3 |
+
from datasets import load_dataset
|
4 |
+
from transformers import pipeline
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
#repo_id = "maviced/practica7-1"
|
8 |
+
#learn = from_pretrained_fastai(repo_id)
|
9 |
+
#model = learn.model
|
10 |
+
#model = model.cpu()
|
11 |
+
|
12 |
+
#repo_id = "maviced/practica7-2"
|
13 |
+
#learn = from_pretrained_fastai(repo_id)
|
14 |
+
#model = learn.model
|
15 |
+
#model = model.cpu()
|
16 |
+
|
17 |
+
classifier = pipeline('text-classification', model='maviced/clasificador-rotten-tomatoes')
|
18 |
+
|
19 |
+
def predict(text):
|
20 |
+
#pred,pred_idx,probs = learner.predict(text)
|
21 |
+
#return pred
|
22 |
+
|
23 |
+
return classifier(text)[0]['label']
|
24 |
+
|
25 |
+
gr.Interface(fn=predict, inputs="text", outputs="text",examples=['A visually stunning and emotionally resonant film that leaves a lasting impact.',
|
26 |
+
'The film, while visually stunning, falls short with a predictable plot and underdeveloped characters, leaving the audience craving more substance.']).launch(share=True)
|