File size: 1,055 Bytes
e076b08
 
 
 
dbf35b4
 
 
 
 
 
54b3f6c
 
 
 
 
 
 
 
39fc371
 
 
 
54b3f6c
343f123
54b3f6c
 
39fc371
 
54b3f6c
39fc371
54b3f6c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pandas as pd
from fastai.text.all import *
from datasets import load_dataset

try:
    import transformers
except ImportError:
    os.system('pip install transformers')
    import transformers

from transformers import pipeline
import gradio as gr

#repo_id = "maviced/practica7-1"
#learn = from_pretrained_fastai(repo_id)
#model = learn.model
#model = model.cpu()

#repo_id = "maviced/practica7-2"
#learn = from_pretrained_fastai(repo_id)
#model = learn.model
#model = model.cpu()

classifier = pipeline('text-classification', model='maviced/clasificador-rotten-tomatoes')

def predict(text):
    #pred,pred_idx,probs = model.predict(text)
    #return pred
    
    return classifier(text)[0]['label']
    
gr.Interface(fn=predict, inputs="text", outputs="text",examples=['A visually stunning and emotionally resonant film that leaves a lasting impact.',
                       'The film, while visually stunning, falls short with a predictable plot and underdeveloped characters, leaving the audience craving more substance.']).launch(share=True)