Spaces:
Sleeping
Sleeping
def calculate_bmi(weight, height,age,gender): | |
height_m = height / 100 | |
bmi = weight / (height_m ** 2) | |
if bmi < 18.5: | |
category = "Underweight π" | |
elif 18.5 <= bmi < 24.9: | |
category = "Normal weight π" | |
elif 25 <= bmi < 29.9: | |
category = "Overweight π" | |
else: | |
category = "Obesity π" | |
return f"BMI: {bmi:.2f} - {category}" | |
import gradio as gr | |
interface = gr.Interface( | |
fn=calculate_bmi, | |
inputs=[ | |
gr.Slider(0, 120, step=1, label="Weight (kg)"), | |
gr.Slider(100, 250, step=1, label="Height (cm)"), | |
gr.Slider(5, 100, step=1, label="AGE(years)"), | |
gr.Radio(["Male", "Female"], label="Gender") | |
], | |
outputs="text", | |
title="BMI CALCULATOR", | |
description="Adjust your weight and height to calculate your BMI.", | |
flagging_dir="flagged_data", | |
examples=[[12,23,3,"Male"], | |
[32,44,2,"Female"]], | |
live=True , ## to eleminate the submitt button | |
flagging_options=["good", "bad", "average"],## option for flag to users | |
theme="Citrus", | |
css = """ | |
body, .container, .block, .output, .input, .slider, .btn-primary, .btn-secondary, .label { | |
background-color: #1E1E1E !important; /* Dark background color */ | |
color: #F5F5F5 !important; /* Light text color */ | |
border-color: #333333 !important; /* Darker border color */ | |
} | |
.slider input[type="range"] { | |
background: linear-gradient(to right, #FF5722, #FFEB3B) !important; /* Gradient for slider */ | |
} | |
.btn-primary { | |
background-color: #4CAF50 !important; /* Green for primary button */ | |
color: #FFFFFF !important; | |
} | |
.btn-secondary { | |
background-color: #FF5722 !important; /* Orange for secondary button */ | |
color: #FFFFFF !important; | |
} | |
.label { | |
font-weight: bold; | |
color: #A0A0A0 !important; /* Softer light color for labels */ | |
} | |
""" | |
) | |
interface.launch(share=True,debug=True) | |