Spaces:
Build error
Build error
Download app.py from joros244/Entregable3: direct link, hf CLI and curl.
- Browser
- Download file 796 Bytes
-
https://huggingface.co/spaces/joros244/Entregable3/resolve/main/app.py
- Command line
-
hf download hf://spaces/joros244/Entregable3/app.py
-
curl -L -o app.py https://huggingface.co/spaces/joros244/Entregable3/resolve/main/app.py
796 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| # Cargamos el learner | |
| learn = load_learner('export.pkl') | |
| # Definimos las etiquetas de nuestro modelo | |
| labels = ['Negative','Neutral','Positive'] | |
| # Definimos una función que se encarga de llevar a cabo las predicciones | |
| def predict(text): | |
| pred,pred_idx,probs = learn.predict(text) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| # Creamos la interfaz y la lanzamos. | |
| gr.Interface(fn=predict, inputs=gr.Textbox(), outputs=gr.outputs.Label(num_top_classes=3),examples=['Some hate humanity, but I love humanity so much.','I have this old 2006 BusinessWeek framed as a reminder. The “risky bet” that Wall Street disliked was AWS, which generated revenue of more than $62 billion last year.']).launch(share=False) |