File size: 806 Bytes
4250e41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
import tensorflow as tf

# Cargar el modelo
model = tf.keras.models.load_model('modelito1.h5')

model.summary()

def inferir(x_entrada):
  x_train_min = -100
  x_train_max = 96
  y_train_min = -90.0
  y_train_max = 106

  x_entrada_normalizado = (x_entrada - x_train_min) / (x_train_max - x_train_min)
  X0 = tf.constant([x_entrada_normalizado], dtype=tf.float32)

  # Realizar la inferencia
  y0_predicted = model.predict(X0)
  y0_normalized = y0_predicted[0][0]
  y0 = y0_normalized * (y_train_max - y_train_min) + y_train_min

  return y0

iface = gr.Interface(
    fn=inferir,
    inputs=gr.Number(label="Entrada"),
    outputs="number",
    title="Inferencia del Modelo",
    description="Introduce un valor para realizar la inferencia con el modelo modelito1.h5"
)

iface.launch()