SS8297 commited on
Commit
798bfeb
·
1 Parent(s): fe044a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -33,6 +33,19 @@ feat.pretrained.get_pretrained_models = _get_pretrained_models
33
 
34
  from feat import Detector
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  os.environ["TWILIO_ACCOUNT_SID"] = "ACf1e76f3fd6e9cbca940decc4ed443c20"
37
  os.environ["TWILIO_AUTH_TOKEN"] = "5cadf5cc7120dd995f11b3dc57e46d52"
38
 
 
33
 
34
  from feat import Detector
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
  os.environ["TWILIO_ACCOUNT_SID"] = "ACf1e76f3fd6e9cbca940decc4ed443c20"
50
  os.environ["TWILIO_AUTH_TOKEN"] = "5cadf5cc7120dd995f11b3dc57e46d52"
51