Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
# Modelo de clasificaci贸n usando LSTM
|
8 |
+
learn = load_learner('modelLSTM.pkl')
|
9 |
+
|
10 |
+
# Modelo de clasificaci贸n de texto usando modelos de lenguaje
|
11 |
+
#learn = load_learner('modelML.pkl')
|
12 |
+
|
13 |
+
# Modelo de clasificaci贸n basados en mecanismos de atenci贸n
|
14 |
+
#classifier = pipeline('text-classification', model='edgilr/clasificador-rotten-tomatoes')
|
15 |
+
|
16 |
+
def predict(txt):
|
17 |
+
# Modelo de clasificaci贸n usando LSTM o modelo de clasificaci贸n de texto usando modelos de lenguaje
|
18 |
+
pred,pred_idx,probs = learner.predict(txt)
|
19 |
+
return pred
|
20 |
+
# Modelo de clasificaci贸n basados en mecanismos de atenci贸n
|
21 |
+
#return classifier(txt)['label']
|
22 |
+
|
23 |
+
gr.Interface(fn=predict, inputs=["text"], outputs=["text"],
|
24 |
+
examples=['lovingly photographed in the manner of a golden book sprung to life , stuart little 2 manages sweetness largely without stickiness .',
|
25 |
+
'the thing looks like a made-for-home-video quickie .']).launch(share=True)
|