Gowthamvemula commited on
Commit
1dc16d2
·
verified ·
1 Parent(s): de96aa5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -1,11 +1,17 @@
1
  import gradio as gr
2
- import joblib
3
  import numpy as np
4
 
5
- # Load the model using joblib
6
- model = joblib.load("log_reg_model.pkl")
 
7
 
8
- # Define prediction function
 
 
 
 
 
 
9
  def predict_sleep(step: float, hour: float):
10
  input_data = np.array([[step, hour]])
11
  prediction = model.predict(input_data)[0]
@@ -24,6 +30,5 @@ iface = gr.Interface(
24
  description="Enter step count and hour to predict whether it's sleep onset or wakeup."
25
  )
26
 
27
- # Launch app
28
  if __name__ == "__main__":
29
  iface.launch()
 
1
  import gradio as gr
 
2
  import numpy as np
3
 
4
+ # # 🟢 Option 1: Load model with joblib
5
+ # import joblib
6
+ # model = joblib.load("log_reg_model.pkl")
7
 
8
+ # 🔵 Option 2: (Use only if model saved with pickle)
9
+
10
+ import pickle
11
+ with open("log_reg_model.pkl", "rb") as f:
12
+ model = pickle.load(f)
13
+
14
+ # Prediction function
15
  def predict_sleep(step: float, hour: float):
16
  input_data = np.array([[step, hour]])
17
  prediction = model.predict(input_data)[0]
 
30
  description="Enter step count and hour to predict whether it's sleep onset or wakeup."
31
  )
32
 
 
33
  if __name__ == "__main__":
34
  iface.launch()