Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|
| 8 |
+
return f"Your BMI is {bmi:.2f}. You have a normal weight."
|
| 9 |
+
else:
|
| 10 |
+
return f"Your BMI is {bmi:.2f}. You are overweight."
|
| 11 |
+
|
| 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 |
+
|
| 22 |
+
# Launch the interface
|
| 23 |
+
interface.launch()
|