File size: 1,228 Bytes
dc41ed9
 
ca15d0d
dc41ed9
8133c27
dc41ed9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
import joblib
import pandas as pd

model=joblib.load("calorie_prediction_model.pkl")

def predict_calories(age, gender, height, weight, duration, heart_rate, body_temp):
    data = pd.DataFrame([{
        "Age": age,
        "Gender": gender,
        "Height": height,
        "Weight": weight,
        "Duration": duration,
        "Heart_Rate": heart_rate,
        "Body_Temp": body_temp
    }])

    prediction = model.predict(data)

    
    return f"🔥 Estimated Calories Burned: {round(prediction[0], 2)}"


app = gr.Interface(
    fn=predict_calories,
    inputs=[
        gr.Slider(10, 80, step=1, label="Age"),
        gr.Radio(["male", "female"], label="Gender"),
        gr.Slider(100, 220, step=1, label="Height (cm)"),
        gr.Slider(30, 150, step=1, label="Weight (kg)"),
        gr.Slider(1, 120, step=1, label="Exercise Duration (minutes)"),
        gr.Slider(60, 200, step=1, label="Heart Rate (bpm)"),
        gr.Slider(35.0, 42.0, step=0.1, label="Body Temperature (°C)")
    ],
    outputs=gr.Textbox(label="🔥 Calories Prediction"),
    title="🧠 Calorie Burn Predictor",
    description="Fill in your workout data to predict how many calories you might burn."
)

app.launch()