Sleep_Detection / app.py
Gowthamvemula's picture
Update app.py
4fdca24 verified
raw
history blame contribute delete
750 Bytes
import gradio as gr
import joblib
import numpy as np
# βœ… Load the model correctly using joblib
model = joblib.load("log_reg_model.pkl")
# Define prediction function
def predict_sleep(step: float, hour: float):
input_data = np.array([[step, hour]])
prediction = model.predict(input_data)[0]
return "Sleep Onset" if prediction == 1 else "Wakeup"
# Gradio interface
iface = gr.Interface(
fn=predict_sleep,
inputs=[
gr.Number(label="Step Count"),
gr.Number(label="Hour (0–23)")
],
outputs=gr.Text(label="Prediction"),
title="Sleep Prediction (Onset/Wakeup)",
description="Enter step count and hour to predict whether it's sleep onset or wakeup."
)
if __name__ == "__main__":
iface.launch()