ancebuc commited on
Commit
5751c3c
1 Parent(s): 8d02e1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -7,6 +7,22 @@ repo_id = "ancebuc/entregable3"
7
  learner = from_pretrained_fastai(repo_id)
8
  labels = [i for i in range(6)]
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Definimos una funci贸n que se encarga de llevar a cabo las predicciones
11
  def predict(text):
12
  #img = PILImage.create(img)
@@ -14,4 +30,4 @@ def predict(text):
14
  return pred[0]
15
 
16
  # Creamos la interfaz y la lanzamos.
17
- gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=gr.outputs.Label()).launch(share=False)
 
7
  learner = from_pretrained_fastai(repo_id)
8
  labels = [i for i in range(6)]
9
 
10
+ def postprocessing(pred):
11
+ if pred[0] == '0':
12
+ return json.dumps({"label": "Sadness"})
13
+ elif pred[0] == '1':
14
+ return json.dumps({"label": "Joy"})
15
+ elif pred[0] == '2':
16
+ return json.dumps({"label": "Love"})
17
+ elif pred[0] == '3':
18
+ return json.dumps({"label": "Anger"})
19
+ elif pred[0] == '4':
20
+ return json.dumps({"label": "Fear"})
21
+ elif pred[0] == '5':
22
+ return json.dumps({"label": "Surprise"})
23
+ else:
24
+ return json.dumps({"label": "Don't know"})
25
+
26
  # Definimos una funci贸n que se encarga de llevar a cabo las predicciones
27
  def predict(text):
28
  #img = PILImage.create(img)
 
30
  return pred[0]
31
 
32
  # Creamos la interfaz y la lanzamos.
33
+ gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=gr.outputs.Label(preprocessing_fn=preprocessing)).launch(share=False)