File size: 676 Bytes
17e1cb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr

def calculate_bmi(weight, height):
    bmi = weight / (height ** 2)
    if bmi < 18.5:
        return f"Your BMI is {bmi:.2f}. You are underweight."
    elif 18.5 <= bmi < 24.9:
        return f"Your BMI is {bmi:.2f}. You have a normal weight."
    else:
        return f"Your BMI is {bmi:.2f}. You are overweight."

# Create the Gradio interface with a title and custom layout
interface = gr.Interface(
    fn=calculate_bmi,
    inputs=["number", "number"],
    outputs="text",
    title="BMI Calculator",
    description="Enter your weight and height to calculate your Body Mass Index (BMI).",
    live=True
)

# Launch the interface
interface.launch()