Ignaciobfp commited on
Commit
2d780cf
·
1 Parent(s): ddee08e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import from_pretrained_fastai
2
+ import gradio as gr
3
+ from fastai.vision.all import *
4
+
5
+ repo_id = "Ignaciobfp/Practica8-modelo"
6
+
7
+ learner = from_pretrained_fastai(repo_id)
8
+ labels = ["negative", "positive"]
9
+
10
+ def predict(opinion):
11
+ pred,pred_idx,probs = learner.predict(opinion)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ # Creamos la interfaz y la lanzamos.
15
+ gr.Interface(fn=predict, inputs=gr.Textbox(lines=2, placeholder="the movie was neither good or bad"), outputs=gr.outputs.Label(num_top_classes=2),
16
+ examples=['the movie was utter shit I would rater sting a stick in my eyes than seeing something remotely similar to this again', 'is the best movie i have ever seen, had action, romance, science fiction elements. As fun as movies will ever get']).launch(share=False)