EugenioRoma commited on
Commit
1a495e3
·
1 Parent(s): 50c43fa

Create functions.py

Browse files
Files changed (1) hide show
  1. functions.py +23 -0
functions.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ # Obteniendo las labels de "https://git.io/JJkYN"
4
+ respuesta = requests.get("https://git.io/JJkYN")
5
+ etiquetas =respuesta.text.split("\n")
6
+
7
+ def classify_imagen(inp):
8
+ inp = inp.reshape((-1, 224, 224, 3))
9
+ inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
10
+ # Modificacion en reshape, para que funcione con decode_predictions
11
+ prediction = inception_net.predict(inp).reshape(1,1000)
12
+ # Nuevo metodo para etiquetar predicciones
13
+ pred_labels = tf.keras.applications.mobilenet_v2.decode_predictions(prediction, top=100)
14
+ confidence = {f'{pred_labels[0][i][1]}': float(pred_labels[0][i][2]) for i in range(100)}
15
+
16
+ return confidence
17
+
18
+ def audio_a_text(audio):
19
+ text = trans(audio)["text"]
20
+ return text
21
+
22
+ def texto_a_sentimiento(text):
23
+ return clasificador(text)[0]["label"]