SS8297 commited on
Commit
e976e6f
·
1 Parent(s): e12cc52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -2
app.py CHANGED
@@ -11,7 +11,9 @@ import math
11
  import torch
12
  from torch import nn
13
  from PIL import Image
 
14
  from feat.utils.io import get_resource_path
 
15
 
16
  CLASS_LABELS = ['angry', 'disgust', 'fear', 'happy', 'neutral', 'sad', 'surprise']
17
 
@@ -20,7 +22,31 @@ def _get_resource_path():
20
 
21
  get_resource_path = _get_resource_path
22
 
23
- from feat import Detector
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  os.environ["TWILIO_ACCOUNT_SID"] = "ACf1e76f3fd6e9cbca940decc4ed443c20"
26
  os.environ["TWILIO_AUTH_TOKEN"] = "5cadf5cc7120dd995f11b3dc57e46d52"
@@ -148,7 +174,7 @@ st.markdown("""
148
  </style>
149
  """, unsafe_allow_html=True)
150
 
151
- detector = Detector(face_model="retinaface", landmark_model= "pfld", au_model = "xgb", emotion_model="resmasknet")
152
  source = "Webcam"
153
  recog = True
154
 
 
11
  import torch
12
  from torch import nn
13
  from PIL import Image
14
+ from feat import Detector
15
  from feat.utils.io import get_resource_path
16
+ from feat.pretrained import get_pretrained_models
17
 
18
  CLASS_LABELS = ['angry', 'disgust', 'fear', 'happy', 'neutral', 'sad', 'surprise']
19
 
 
22
 
23
  get_resource_path = _get_resource_path
24
 
25
+ def _get_pretrained_models(face_model, landmark_model, au_model, emotion_model, facepose_model, verbose):
26
+ return (
27
+ face_model,
28
+ landmark_model,
29
+ au_model,
30
+ emotion_model,
31
+ facepose_model,
32
+ )
33
+ get_pretrained_models = _get_pretrained_models
34
+
35
+
36
+ def _calculate_md5(fpath: str, chunk_size: int = 1024 * 1024) -> str:
37
+ # Setting the `usedforsecurity` flag does not change anything about the functionality, but indicates that we are
38
+ # not using the MD5 checksum for cryptography. This enables its usage in restricted environments like FIPS. Without
39
+ # it torchvision.datasets is unusable in these environments since we perform a MD5 check everywhere.
40
+ if sys.version_info >= (3, 9):
41
+ md5 = hashlib.md5(usedforsecurity=True)
42
+ else:
43
+ md5 = hashlib.md5()
44
+ with open(fpath, "rb") as f:
45
+ while chunk := f.read(chunk_size):
46
+ md5.update(chunk)
47
+ return md5.hexdigest()
48
+
49
+
50
 
51
  os.environ["TWILIO_ACCOUNT_SID"] = "ACf1e76f3fd6e9cbca940decc4ed443c20"
52
  os.environ["TWILIO_AUTH_TOKEN"] = "5cadf5cc7120dd995f11b3dc57e46d52"
 
174
  </style>
175
  """, unsafe_allow_html=True)
176
 
177
+ detector = Detector(face_model="retinaface", landmark_model= "pfld", au_model="xgb", facepose_model="img2pose", emotion_model="resmasknet")
178
  source = "Webcam"
179
  recog = True
180