ancebuc commited on
Commit
9b76704
1 Parent(s): cae5887

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -19
app.py CHANGED
@@ -5,24 +5,9 @@ from fastai.vision.all import *
5
  repo_id = "ancebuc/entregable3"
6
 
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,5 +15,4 @@ def predict(text):
30
  return pred
31
 
32
  # Creamos la interfaz y la lanzamos.
33
- label = gr.outputs.Label(postprocessing_fn=postprocessing)
34
- gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=label).launch(share=False)
 
5
  repo_id = "ancebuc/entregable3"
6
 
7
  learner = from_pretrained_fastai(repo_id)
8
+ labels = ['Sadness', 'Joy', 'Love', 'Anger', 'Fear', 'Surprise']
9
 
10
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  # Definimos una funci贸n que se encarga de llevar a cabo las predicciones
12
  def predict(text):
13
  #img = PILImage.create(img)
 
15
  return pred
16
 
17
  # Creamos la interfaz y la lanzamos.
18
+ gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=gr.outputs.Label()).launch(share=False)