sudo-paras-shah commited on
Commit
ec56169
·
1 Parent(s): 3f28202

Add async processing

Browse files

Improve performance

Improve face detection parameters

src/classification.py CHANGED
@@ -9,11 +9,10 @@ import tempfile
9
  class Classification:
10
  def __init__(self, model_choice):
11
  self.model_choice = model_choice
12
- self.classes_path = "src/model_data/cls_classes.txt"
13
  self.input_shape = (224, 224)
14
  self.alpha = 0.25
15
 
16
- # Download the model from Hugging Face
17
  cache_dir = os.path.join(tempfile.gettempdir(), "hf_cache")
18
  os.makedirs(cache_dir, exist_ok=True)
19
  self.model_path = hf_hub_download(
@@ -22,10 +21,8 @@ class Classification:
22
  cache_dir=cache_dir
23
  )
24
 
25
- # Load class names
26
  self.class_names, self.num_classes = get_classes(self.classes_path)
27
-
28
- # Load model
29
  self.load_model()
30
 
31
  def load_model(self):
 
9
  class Classification:
10
  def __init__(self, model_choice):
11
  self.model_choice = model_choice
12
+ self.classes_path = "src/cls_classes.txt"
13
  self.input_shape = (224, 224)
14
  self.alpha = 0.25
15
 
 
16
  cache_dir = os.path.join(tempfile.gettempdir(), "hf_cache")
17
  os.makedirs(cache_dir, exist_ok=True)
18
  self.model_path = hf_hub_download(
 
21
  cache_dir=cache_dir
22
  )
23
 
24
+ # Load class names and model
25
  self.class_names, self.num_classes = get_classes(self.classes_path)
 
 
26
  self.load_model()
27
 
28
  def load_model(self):
src/{model_data/cls_classes.txt → cls_classes.txt} RENAMED
File without changes
src/model_data/haarcascade_frontalface_alt.xml DELETED
The diff for this file is too large to render. See raw diff
 
src/model_data/mobilenet_2_5_224_tf_no_top.h5 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:dbdb03ee2a22fd895301636cd328b234bb3a9952358f436d82f46b81e0d5b0bf
3
- size 2108140
 
 
 
 
src/model_data/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bfe5187d0a272bed55ba430631598124cff8e880b98d38c9e56c8d66032abdc1
3
- size 58889256
 
 
 
 
src/streamlit_app.py CHANGED
@@ -82,7 +82,7 @@ if __name__ == '__main__':
82
  faces = face_cascade.detectMultiScale(
83
  img_gray,
84
  scaleFactor=1.1,
85
- minNeighbors=1,
86
  minSize=(30, 30)
87
  )
88
  return img, img_gray, faces
@@ -198,6 +198,7 @@ if __name__ == '__main__':
198
  video_processor_factory=EmotionRecognitionProcessor,
199
  rtc_configuration=RTC_CONFIGURATION,
200
  media_stream_constraints={"video": True, "audio": False},
 
201
  )
202
 
203
  history = list(shared_emotion_history)
 
82
  faces = face_cascade.detectMultiScale(
83
  img_gray,
84
  scaleFactor=1.1,
85
+ minNeighbors=3,
86
  minSize=(30, 30)
87
  )
88
  return img, img_gray, faces
 
198
  video_processor_factory=EmotionRecognitionProcessor,
199
  rtc_configuration=RTC_CONFIGURATION,
200
  media_stream_constraints={"video": True, "audio": False},
201
+ async_processing=True,
202
  )
203
 
204
  history = list(shared_emotion_history)