mahernto commited on
Commit
6ad695c
·
verified ·
1 Parent(s): 105d833

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
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
- labels = learner.dls.vocab
9
- # Función de predicción
10
  def predict(text):
11
- pred = learner.predict(text)
12
- if (str(pred) == "0"):
13
  return "Negative"
14
- elif (str(pred) == "1"):
15
  return "Positive"
16
  else:
17
  return "Error"
18
 
19
- # Interfaz Gradio
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)