1 Commits
Author SHA1 Message Date
VS f17ff1e98a Fix 2026-09-25 12:21:47 +02:00
+12 -6
View File
@@ -10,7 +10,8 @@ from retinaface import RetinaFace
treashold = float(os.getenv('FACE_TRASHOLD', '0.9'))
sever = os.getenv('API_ROOT', 'localhost:8000')
disk_treashold = os.getenv('DISK_FREE_TRASHOLD', 10)
disk_treashold = float(os.getenv('DISK_FREE_TRASHOLD', '10.0'))
disk_treashold_gb = float(os.getenv('DISK_FREE_TRASHOLD_GB', '20.0'))
root_api_url = 'http://{}/local'.format(sever)
base_path = '/app/data/'
@@ -18,6 +19,7 @@ base_path = '/app/data/'
print("API_ROOT: " + str(root_api_url), flush=True)
print("FACE_TRASHOLD: " + str(treashold), flush=True)
print("DISK_FREE_TRASHOLD: " + str(disk_treashold), flush=True)
print("DISK_FREE_TRASHOLD_GB: " + str(disk_treashold_gb), flush=True)
try:
while True:
@@ -26,10 +28,14 @@ try:
#Chesk if there is enought free space at destination path
while True:
total, used, free = shutil.disk_usage(base_path)
if (free // (2**30)) > ((total / 100) * disk_treashold) // (2**30):
free_gb = free / (2**30)
below_percent = free < (total / 100) * disk_treashold
not_above_gb = free_gb <= disk_treashold_gb
# Not enough space only if free space is below the % threshold AND not above the GB threshold
if not (below_percent and not_above_gb):
break
data = {"trace": "not enought free space at destination" + str(base_path) + " trashold is: " + str(disk_treashold) + "%"}
data = {"trace": "not enought free space at destination" + str(base_path) + " trashold is: " + str(disk_treashold) + "% and " + str(disk_treashold_gb) + " GB"}
response = requests.post('{}/log'.format(root_api_url), json=data)
print("sleep", flush=True)
@@ -43,7 +49,7 @@ try:
for detection in response:
print(str(detection['id']) + " Anonymization Started", flush=True)
img_path = "{}{}".format(base_path, detection['path'])
img_path = "{}{}".format(base_path, detection['source_image_path'])
#print(img_path, flush=True)
#Skip Non existing files
if (not os.path.exists(img_path)):
@@ -57,7 +63,7 @@ try:
if (len(faces) <= 0):
data = {
"id": detection['id'],
"path": img_path.replace(base_path,""),
"source_image_path": img_path.replace(base_path,""),
"face_found": 0,
}
response = requests.post('{}/anonymize'.format(root_api_url), json=data)
@@ -93,7 +99,7 @@ try:
data = {
"id": detection['id'],
"path": new_img_path.replace(base_path,""),
"source_image_path": new_img_path.replace(base_path,""),
"face_found": len(faces),
}
response = requests.post('{}/anonymize'.format(root_api_url), json=data)