Parthebhan commited on
Commit
363fbe6
Β·
verified Β·
1 Parent(s): b994077

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -1,25 +1,30 @@
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 \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"
23
  )
24
-
25
  bmi.launch(share=True)
 
1
  import gradio as gr
2
 
3
+ def calculate_bmi(Name,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
+ emoji = "😒"
11
  elif bmi >= 18.5 and bmi <= 24.9:
12
  category = "Normal weight"
13
+ emoji = "😊"
14
  elif bmi >= 25 and bmi <= 29.9:
15
  category = "Overweight"
16
+ emoji = "πŸ˜•"
17
  else:
18
  category = "Obesity"
19
+ emoji = "😱"
20
 
21
+ return f"Name :{Name}\n\nYour BMI: {bmi:.2f}\nCategory: {category} {emoji} \n\n Kindly hit flag if you are able to get BMI"
22
 
23
  bmi = gr.Interface(fn=calculate_bmi,
24
+ inputs=['text',
25
+ gr.Slider(0,220, label="Height in cm"),
26
+ gr.Slider(0,130, label="Weight in kg")],
27
+ outputs = "text",title="BMI Calculator in Metrics",
28
  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"
29
  )
 
30
  bmi.launch(share=True)