Spaces:
Runtime error
Runtime error
import gradio as gr | |
def calculate_bmi(Name,height_cm, weight_kg): | |
height_cm = height_cm / 100 # Convert height from cm to meters | |
bmi = weight_kg / (height_cm ** 2) # Calculate BMI | |
# Categorize BMI | |
if bmi < 18.5: | |
category = "Underweight " | |
emoji = "π’" | |
elif bmi >= 18.5 and bmi <= 24.9: | |
category = "Normal weight" | |
emoji = "π" | |
elif bmi >= 25 and bmi <= 29.9: | |
category = "Overweight" | |
emoji = "π" | |
else: | |
category = "Obesity" | |
emoji = "-π±-" | |
return f"Name : {Name}\n\nYour BMI: {bmi:.2f}\nCategory: {category} {emoji} " | |
bmi = gr.Interface(fn=calculate_bmi, | |
inputs=['text', | |
gr.Slider(0, 220, label="Height in cm"), | |
gr.Slider(0, 130, label="Weight in kg")], | |
outputs="text", | |
title="BMI Calculator in Metrics", | |
description="Calculate your BMI (Body Mass Index) based on height **(cm)** and weight **(kg)**.\n\nDeveloped by: Parthebhan Pari \n\n**BMI Categories:**\n- Underweight = <18.5\n- Normal weight = 18.5β24.9\n- Overweight = 25β29.9\n- Obesity = BMI of 30 or greater", | |
) | |
bmi.launch() | |