jaimin commited on
Commit
a2aec99
·
verified ·
1 Parent(s): 908c5e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -8,11 +8,19 @@ import dlib
8
  import cv2
9
  from keras.preprocessing.image import img_to_array
10
  from keras.models import load_model
 
11
 
12
  # Define global variables
13
  points = []
14
  emotion_classifier = None
15
 
 
 
 
 
 
 
 
16
  def eye_brow_distance(leye, reye):
17
  global points
18
  distq = dist.euclidean(leye, reye)
@@ -41,9 +49,8 @@ def normalize_values(points, disp):
41
  def stress(video_path, duration):
42
  global points, emotion_classifier
43
  detector = dlib.get_frontal_face_detector()
44
- predictor_path = "Stress/shape_predictor_68_face_landmarks.dat"
45
  predictor = dlib.shape_predictor(predictor_path)
46
- emotion_classifier = load_model("Stress/XCEPTION.102-0.66.hdf5", compile=False)
47
 
48
  # Open video file
49
  cap = cv2.VideoCapture(video_path)
@@ -118,4 +125,3 @@ gr.Interface(
118
  outputs="json",
119
  title="Heart Rate and Stress Measurement"
120
  ).launch(server_name="0.0.0.0")
121
-
 
8
  import cv2
9
  from keras.preprocessing.image import img_to_array
10
  from keras.models import load_model
11
+ from huggingface_hub import hf_hub_download
12
 
13
  # Define global variables
14
  points = []
15
  emotion_classifier = None
16
 
17
+ # Define Hugging Face repository details
18
+ repo_id = "jaimin/Age_detection"
19
+
20
+ # Download model files from Hugging Face
21
+ predictor_path = hf_hub_download(repo_id=repo_id, filename="shape_predictor_68_face_landmarks.dat")
22
+ emotion_model_path = hf_hub_download(repo_id=repo_id, filename="XCEPTION.102-0.66.hdf5")
23
+
24
  def eye_brow_distance(leye, reye):
25
  global points
26
  distq = dist.euclidean(leye, reye)
 
49
  def stress(video_path, duration):
50
  global points, emotion_classifier
51
  detector = dlib.get_frontal_face_detector()
 
52
  predictor = dlib.shape_predictor(predictor_path)
53
+ emotion_classifier = load_model(emotion_model_path, compile=False)
54
 
55
  # Open video file
56
  cap = cv2.VideoCapture(video_path)
 
125
  outputs="json",
126
  title="Heart Rate and Stress Measurement"
127
  ).launch(server_name="0.0.0.0")