SuriRaja commited on
Commit
46d6884
·
verified ·
1 Parent(s): 3581b9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -35,6 +35,7 @@ hemoglobin_model = joblib.load("hemoglobin_model_from_anemia_dataset.pkl")
35
  hemoglobin_r2 = 0.385
36
  import joblib
37
  spo2_model = joblib.load("spo2_model_simulated.pkl")
 
38
 
39
  models = {
40
  "Hemoglobin": hemoglobin_model,
@@ -100,7 +101,12 @@ def analyze_face(image):
100
  value = models[label].predict([[random.uniform(0.2, 0.5) for _ in range(7)]])[0]
101
  test_values[label] = value
102
  r2_scores[label] = 0.0 # simulate other 7D inputs
103
- heart_rate = int(60 + 30 * np.sin(np.mean(frame_rgb) / 255.0 * np.pi))
 
 
 
 
 
104
  skin_patch = frame_rgb[100:150, 100:150]
105
  skin_tone_index = np.mean(skin_patch) / 255 if skin_patch.size else 0.5
106
  brightness_variation = np.std(cv2.cvtColor(frame_rgb, cv2.COLOR_RGB2GRAY)) / 255
 
35
  hemoglobin_r2 = 0.385
36
  import joblib
37
  spo2_model = joblib.load("spo2_model_simulated.pkl")
38
+ hr_model = joblib.load("heart_rate_model.pkl")
39
 
40
  models = {
41
  "Hemoglobin": hemoglobin_model,
 
101
  value = models[label].predict([[random.uniform(0.2, 0.5) for _ in range(7)]])[0]
102
  test_values[label] = value
103
  r2_scores[label] = 0.0 # simulate other 7D inputs
104
+ gray = cv2.cvtColor(frame_rgb, cv2.COLOR_RGB2GRAY)
105
+ green_std = np.std(frame_rgb[:, :, 1]) / 255
106
+ brightness_std = np.std(gray) / 255
107
+ tone_index = np.mean(frame_rgb[100:150, 100:150]) / 255 if frame_rgb[100:150, 100:150].size else 0.5
108
+ hr_features = [brightness_std, green_std, tone_index]
109
+ heart_rate = hr_model.predict([hr_features])[0]
110
  skin_patch = frame_rgb[100:150, 100:150]
111
  skin_tone_index = np.mean(skin_patch) / 255 if skin_patch.size else 0.5
112
  brightness_variation = np.std(cv2.cvtColor(frame_rgb, cv2.COLOR_RGB2GRAY)) / 255