File size: 805 Bytes
1a495e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests

# Obteniendo las labels de "https://git.io/JJkYN"
respuesta = requests.get("https://git.io/JJkYN")
etiquetas =respuesta.text.split("\n")

def classify_imagen(inp):
  inp = inp.reshape((-1, 224, 224, 3))
  inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
  # Modificacion en reshape, para que funcione con decode_predictions
  prediction = inception_net.predict(inp).reshape(1,1000)
  # Nuevo metodo para etiquetar predicciones
  pred_labels = tf.keras.applications.mobilenet_v2.decode_predictions(prediction, top=100)
  confidence = {f'{pred_labels[0][i][1]}': float(pred_labels[0][i][2]) for i in range(100)}
  
  return confidence

def audio_a_text(audio):
  text = trans(audio)["text"]
  return text

def texto_a_sentimiento(text):
  return clasificador(text)[0]["label"]