Update app.py
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ def conversar_coach(mensaje, historial):
|
|
| 31 |
return historial, ""
|
| 32 |
|
| 33 |
# ---------- CÁLCULO DE CALORÍAS ---------- #
|
| 34 |
-
def calcular_calorias(edad, peso, altura, genero, actividad):
|
| 35 |
global calorias_totales, calorias_restantes
|
| 36 |
if genero.lower() == "mujer":
|
| 37 |
bmr = 655 + (9.6 * peso) + (1.8 * altura) - (4.7 * edad)
|
|
@@ -45,9 +45,20 @@ def calcular_calorias(edad, peso, altura, genero, actividad):
|
|
| 45 |
"activo": 1.725,
|
| 46 |
"muy activo": 1.9
|
| 47 |
}
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
calorias_restantes = calorias_totales
|
| 50 |
-
return f"🔥 Puedes consumir aproximadamente **{calorias_totales} calorías por día
|
|
|
|
| 51 |
|
| 52 |
# ---------- SIMULACIÓN DE RELOJ INTELIGENTE ---------- #
|
| 53 |
def calorias_reloj(calorias_quemadas):
|
|
@@ -159,7 +170,7 @@ def main():
|
|
| 159 |
gr.Markdown("# 🧠 Bienvenido a **NutriBot IA** 🍎")
|
| 160 |
gr.Markdown("Calcula tus calorías, registra tus comidas con fotos, y mantén tu bienestar diario 🌿")
|
| 161 |
|
| 162 |
-
|
| 163 |
with gr.Tab("📊 Calorías Diarias"):
|
| 164 |
with gr.Row():
|
| 165 |
edad = gr.Number(label="Edad (años)")
|
|
@@ -167,9 +178,11 @@ def main():
|
|
| 167 |
altura = gr.Number(label="Altura (cm)")
|
| 168 |
genero = gr.Radio(["Hombre", "Mujer"], label="Género")
|
| 169 |
actividad = gr.Dropdown(["Sedentario", "Ligero", "Moderado", "Activo", "Muy activo"], label="Nivel de actividad")
|
|
|
|
| 170 |
boton_calcular = gr.Button("Calcular Calorías 🔥")
|
| 171 |
salida_calorias = gr.Markdown()
|
| 172 |
-
boton_calcular.click(calcular_calorias, inputs=[edad, peso, altura, genero, actividad], outputs=salida_calorias)
|
|
|
|
| 173 |
|
| 174 |
# --- FOTO DE COMIDA --- #
|
| 175 |
with gr.Tab("📸 Registro de Comidas"):
|
|
|
|
| 31 |
return historial, ""
|
| 32 |
|
| 33 |
# ---------- CÁLCULO DE CALORÍAS ---------- #
|
| 34 |
+
def calcular_calorias(edad, peso, altura, genero, actividad, meta):
|
| 35 |
global calorias_totales, calorias_restantes
|
| 36 |
if genero.lower() == "mujer":
|
| 37 |
bmr = 655 + (9.6 * peso) + (1.8 * altura) - (4.7 * edad)
|
|
|
|
| 45 |
"activo": 1.725,
|
| 46 |
"muy activo": 1.9
|
| 47 |
}
|
| 48 |
+
|
| 49 |
+
calorias_base = bmr * factores.get(actividad.lower(), 1.55)
|
| 50 |
+
|
| 51 |
+
# Ajuste según meta del usuario
|
| 52 |
+
if meta.lower() == "bajar de peso":
|
| 53 |
+
calorias_totales = round(calorias_base * 0.8)
|
| 54 |
+
elif meta.lower() == "subir de peso":
|
| 55 |
+
calorias_totales = round(calorias_base * 1.15)
|
| 56 |
+
else:
|
| 57 |
+
calorias_totales = round(calorias_base)
|
| 58 |
+
|
| 59 |
calorias_restantes = calorias_totales
|
| 60 |
+
return f"🎯 Tu meta es **{meta.lower()}**.\n🔥 Puedes consumir aproximadamente **{calorias_totales} calorías por día**."
|
| 61 |
+
|
| 62 |
|
| 63 |
# ---------- SIMULACIÓN DE RELOJ INTELIGENTE ---------- #
|
| 64 |
def calorias_reloj(calorias_quemadas):
|
|
|
|
| 170 |
gr.Markdown("# 🧠 Bienvenido a **NutriBot IA** 🍎")
|
| 171 |
gr.Markdown("Calcula tus calorías, registra tus comidas con fotos, y mantén tu bienestar diario 🌿")
|
| 172 |
|
| 173 |
+
# --- CALCULADORA --- #
|
| 174 |
with gr.Tab("📊 Calorías Diarias"):
|
| 175 |
with gr.Row():
|
| 176 |
edad = gr.Number(label="Edad (años)")
|
|
|
|
| 178 |
altura = gr.Number(label="Altura (cm)")
|
| 179 |
genero = gr.Radio(["Hombre", "Mujer"], label="Género")
|
| 180 |
actividad = gr.Dropdown(["Sedentario", "Ligero", "Moderado", "Activo", "Muy activo"], label="Nivel de actividad")
|
| 181 |
+
meta = gr.Radio(["Bajar de peso", "Mantener peso", "Subir de peso"], label="Meta personal 🎯")
|
| 182 |
boton_calcular = gr.Button("Calcular Calorías 🔥")
|
| 183 |
salida_calorias = gr.Markdown()
|
| 184 |
+
boton_calcular.click(calcular_calorias, inputs=[edad, peso, altura, genero, actividad, meta], outputs=salida_calorias)
|
| 185 |
+
|
| 186 |
|
| 187 |
# --- FOTO DE COMIDA --- #
|
| 188 |
with gr.Tab("📸 Registro de Comidas"):
|