pratikshahp commited on
Commit
750ebae
·
verified ·
1 Parent(s): 17e1cb8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,7 +1,13 @@
1
  import gradio as gr
2
 
3
- def calculate_bmi(weight, height):
4
- bmi = weight / (height ** 2)
 
 
 
 
 
 
5
  if bmi < 18.5:
6
  return f"Your BMI is {bmi:.2f}. You are underweight."
7
  elif 18.5 <= bmi < 24.9:
@@ -12,10 +18,14 @@ def calculate_bmi(weight, height):
12
  # Create the Gradio interface with a title and custom layout
13
  interface = gr.Interface(
14
  fn=calculate_bmi,
15
- inputs=["number", "number"],
 
 
 
 
16
  outputs="text",
17
  title="BMI Calculator",
18
- description="Enter your weight and height to calculate your Body Mass Index (BMI).",
19
  live=True
20
  )
21
 
 
1
  import gradio as gr
2
 
3
+ def calculate_bmi(weight, feet, inches):
4
+ # Convert height to meters (1 foot = 0.3048 meters, 1 inch = 0.0254 meters)
5
+ height_in_meters = (feet * 0.3048) + (inches * 0.0254)
6
+
7
+ # Calculate BMI
8
+ bmi = weight / (height_in_meters ** 2)
9
+
10
+ # Return BMI category
11
  if bmi < 18.5:
12
  return f"Your BMI is {bmi:.2f}. You are underweight."
13
  elif 18.5 <= bmi < 24.9:
 
18
  # Create the Gradio interface with a title and custom layout
19
  interface = gr.Interface(
20
  fn=calculate_bmi,
21
+ inputs=[
22
+ gr.Number(label="Weight (kg)"), # Input for weight
23
+ gr.Number(label="Feet"), # Input for feet
24
+ gr.Number(label="Inches") # Input for inches
25
+ ],
26
  outputs="text",
27
  title="BMI Calculator",
28
+ description="Enter your weight in kilograms (kg), height in feet, and inches to calculate your Body Mass Index (BMI).",
29
  live=True
30
  )
31