Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,20 +2,16 @@ from fastai.text.all import *
|
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import from_pretrained_fastai
|
| 4 |
|
| 5 |
-
# Cargar el modelo
|
| 6 |
repo_id = "mahernto/imdbmodel"
|
| 7 |
learner = from_pretrained_fastai(repo_id)
|
| 8 |
-
|
| 9 |
-
# Función de predicción
|
| 10 |
def predict(text):
|
| 11 |
-
pred = learner.predict(text)
|
| 12 |
-
if (
|
| 13 |
return "Negative"
|
| 14 |
-
elif (
|
| 15 |
return "Positive"
|
| 16 |
else:
|
| 17 |
return "Error"
|
| 18 |
|
| 19 |
-
|
| 20 |
-
demo = gr.Interface(fn=predict, inputs=gr.Textbox(lines=4, placeholder="Write your film review..."), outputs="text",examples=["An outstanding film with powerful performances and a moving story. A must-watch.","Terrible acting and a weak script. Not worth watching."])
|
| 21 |
-
demo.launch(share=False)
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import from_pretrained_fastai
|
| 4 |
|
|
|
|
| 5 |
repo_id = "mahernto/imdbmodel"
|
| 6 |
learner = from_pretrained_fastai(repo_id)
|
| 7 |
+
|
|
|
|
| 8 |
def predict(text):
|
| 9 |
+
pred,pred_idx,probs = learner.predict(text)
|
| 10 |
+
if (pred == "0"):
|
| 11 |
return "Negative"
|
| 12 |
+
elif (pred == "1"):
|
| 13 |
return "Positive"
|
| 14 |
else:
|
| 15 |
return "Error"
|
| 16 |
|
| 17 |
+
gr.Interface(fn=predict, inputs=gr.Textbox(lines=4, placeholder="Write your film review..."), outputs="text",examples=["An outstanding film with powerful performances and a moving story. A must-watch.","Terrible acting and a weak script. Not worth watching."]).launch(share=False)
|
|
|
|
|
|