Parthebhan commited on
Commit
66e48b4
·
verified ·
1 Parent(s): bf59a92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def calculate_bmi(height_cm, weight_kg):
4
+ height_cm = height_cm / 100 # Convert height from cm to meters
5
+ bmi = weight_kg / (height_cm ** 2) # Calculate BMI
6
+
7
+ # Categorize BMI
8
+ if bmi < 18.5:
9
+ category = "Underweight"
10
+ elif bmi >= 18.5 and bmi <= 24.9:
11
+ category = "Normal weight"
12
+ elif bmi >= 25 and bmi <= 29.9:
13
+ category = "Overweight"
14
+ else:
15
+ category = "Obesity"
16
+
17
+ return f"Your BMI: {bmi:.2f}\nCategory: {category}"
18
+
19
+ bmi = gr.Interface(fn=calculate_bmi,
20
+ inputs=['number','number'],
21
+ outputs="text", title="BMI Calculator in Metrics",
22
+ description="Calculate your BMI (Body Mass Index) based on height **(cm)** and weight **(kg)**.\n\nDeveloped by: Parthebhan Pari"
23
+ )
24
+ bmi.launch(share=True)