Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def calculate_bmi(weight, height,age,gender):
|
2 |
+
|
3 |
+
height_m = height / 100
|
4 |
+
|
5 |
+
bmi = weight / (height_m ** 2)
|
6 |
+
if bmi < 18.5:
|
7 |
+
category = "Underweight π"
|
8 |
+
elif 18.5 <= bmi < 24.9:
|
9 |
+
category = "Normal weight π"
|
10 |
+
elif 25 <= bmi < 29.9:
|
11 |
+
category = "Overweight π"
|
12 |
+
else:
|
13 |
+
category = "Obesity π"
|
14 |
+
return f"BMI: {bmi:.2f} - {category}"
|
15 |
+
|
16 |
+
import gradio as gr
|
17 |
+
|
18 |
+
interface = gr.Interface(
|
19 |
+
fn=calculate_bmi,
|
20 |
+
inputs=[
|
21 |
+
gr.Slider(0, 120, step=1, label="Weight (kg)"),
|
22 |
+
gr.Slider(100, 250, step=1, label="Height (cm)"),
|
23 |
+
gr.Slider(5, 100, step=1, label="AGE(years)"),
|
24 |
+
gr.Radio(["Male", "Female"], label="Gender")
|
25 |
+
],
|
26 |
+
outputs="text",
|
27 |
+
title="BMI CALCULATOR",
|
28 |
+
description="Adjust your weight and height to calculate your BMI.",
|
29 |
+
flagging_dir="flagged_data",
|
30 |
+
examples=[[12,23,3,"Male"],
|
31 |
+
[32,44,2,"Female"]],
|
32 |
+
live=True , ## to eleminate the submitt button
|
33 |
+
flagging_options=["good", "bad", "average"],## option for flag to users
|
34 |
+
theme="Citrus",
|
35 |
+
css = """
|
36 |
+
body, .container, .block, .output, .input, .slider, .btn-primary, .btn-secondary, .label {
|
37 |
+
background-color: #1E1E1E !important; /* Dark background color */
|
38 |
+
color: #F5F5F5 !important; /* Light text color */
|
39 |
+
border-color: #333333 !important; /* Darker border color */
|
40 |
+
}
|
41 |
+
.slider input[type="range"] {
|
42 |
+
background: linear-gradient(to right, #FF5722, #FFEB3B) !important; /* Gradient for slider */
|
43 |
+
}
|
44 |
+
.btn-primary {
|
45 |
+
background-color: #4CAF50 !important; /* Green for primary button */
|
46 |
+
color: #FFFFFF !important;
|
47 |
+
}
|
48 |
+
.btn-secondary {
|
49 |
+
background-color: #FF5722 !important; /* Orange for secondary button */
|
50 |
+
color: #FFFFFF !important;
|
51 |
+
}
|
52 |
+
.label {
|
53 |
+
font-weight: bold;
|
54 |
+
color: #A0A0A0 !important; /* Softer light color for labels */
|
55 |
+
}
|
56 |
+
"""
|
57 |
+
)
|
58 |
+
|
59 |
+
interface.launch(share=True,debug=True,auth=("deepesh","deepesh1"),auth_message="cheak the <strong>credentials</strong> in email")
|