Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import numpy as np | |
| import joblib | |
| # Load model with joblib | |
| model = joblib.load("random_forest_model.pkl") | |
| st.title("AI Sleep State Detection") | |
| st.markdown("Enter **angle** and **enmo** to predict the sleep state:") | |
| angle = st.number_input("Angle", min_value=-360.0, max_value=360.0, step=0.1) | |
| enmo = st.number_input("ENMO", min_value=0.0, max_value=10.0, step=0.0001, format="%.4f") | |
| if st.button("Detect Sleep State"): | |
| # Normalize angle to be within 0–360 | |
| normalized_angle = angle % 360 | |
| input_data = np.array([[normalized_angle, enmo]]) | |
| prediction = model.predict(input_data)[0] | |
| if prediction == 0: | |
| st.success("Sleep State: **Wakeup**") | |
| else: | |
| st.success("Sleep State: **Onset**") |