Spaces:
Runtime error
Runtime error
File size: 1,260 Bytes
66e48b4 363fbe6 66e48b4 363fbe6 66e48b4 363fbe6 66e48b4 363fbe6 66e48b4 34dbfaf 66e48b4 1643b15 a03f801 1e02b37 b5e79e6 |
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
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()
|