Practica7 / app.py
edgilr's picture
Update app.py
1e03efb verified
raw
history blame
1.09 kB
import pandas as pd
from fastai.text.all import *
from datasets import load_dataset
from transformers import pipeline
import gradio as gr
# Modelo de clasificaci贸n usando LSTM
#learner = load_learner('modelLSTM.pkl')
# Modelo de clasificaci贸n de texto usando modelos de lenguaje
#learner = load_learner('modelML.pkl')
# Modelo de clasificaci贸n basados en mecanismos de atenci贸n
classifier = pipeline('text-classification', model='edgilr/clasificador-rotten-tomatoes')
def predict(txt):
# Modelo de clasificaci贸n usando LSTM o modelo de clasificaci贸n de texto usando modelos de lenguaje
#pred,pred_idx,probs = learner.predict(txt)
#return pred
# Modelo de clasificaci贸n basados en mecanismos de atenci贸n
return classifier(txt)[0]['label']
gr.Interface(fn=predict, inputs="text", outputs="text",
examples=['the story gives ample opportunity for large-scale action and suspense , which director shekhar kapur supplies with tremendous skill .',
'the thing looks like a made-for-home-video quickie .']).launch(share=True)