This commit is contained in:
JonatanRek
2024-10-05 22:21:48 +02:00
parent 5a5fc5e840
commit 75ad53082a
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -19,6 +19,6 @@ COPY . /app
RUN pip install --no-cache-dir -r /app/requirements.txt RUN pip install --no-cache-dir -r /app/requirements.txt
# Start Anonimization # Start Anonimization
CMD ["python", "-u","/app/app.py"] CMD ["python", "-u", "/app/app.py"]
WORKDIR /app WORKDIR /app
+9 -9
View File
@@ -9,18 +9,18 @@ sever = os.getenv('API_ROOT', 'localhost:8000')
root_api_url = 'http://{}/local'.format(sever) root_api_url = 'http://{}/local'.format(sever)
base_path = '/app/data/' base_path = '/app/data/'
print("API_ROOT: " + str(root_api_url)) print("API_ROOT: " + str(root_api_url), flush=True)
time.sleep(900) time.sleep(900)
try: try:
while True: while True:
r = requests.get('{}/anonymize'.format(root_api_url)) r = requests.get('{}/anonymize'.format(root_api_url))
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml') face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
# print(r.text) # print(r.text, flush=True)
response = r.json() response = r.json()
for detection in response: for detection in response:
print(str(detection['id']) + " Anonymization Started") print(str(detection['id']) + " Anonymization Started", flush=True)
img_path = "{}{}".format(base_path, detection['source_image_path']) img_path = "{}{}".format(base_path, detection['source_image_path'])
@@ -33,7 +33,7 @@ try:
faces, rejects, weights = face_cascade.detectMultiScale3(gray, 1.1, 4, outputRejectLevels = 1) faces, rejects, weights = face_cascade.detectMultiScale3(gray, 1.1, 4, outputRejectLevels = 1)
#Count faces is null dont anonimize file #Count faces is null dont anonimize file
print(len(faces) + " Faces Found" ) print(len(faces) + " Faces Found" , flush=True)
if (len(faces) < 0): if (len(faces) < 0):
continue continue
@@ -45,7 +45,7 @@ try:
blurred_face = cv2.GaussianBlur(face_roi, (99, 99), 50) blurred_face = cv2.GaussianBlur(face_roi, (99, 99), 50)
img[y:y+h, x:x+w] = blurred_face img[y:y+h, x:x+w] = blurred_face
print(weights[i]) print(weights[i], flush=True)
text = "{}".format(weights[i]) text = "{}".format(weights[i])
#cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2) #cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)
#cv2.putText(img, text, (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 0, 255), 2) #cv2.putText(img, text, (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 0, 255), 2)
@@ -61,15 +61,15 @@ try:
"source_image_path": new_img_path.replace(base_path,"") "source_image_path": new_img_path.replace(base_path,"")
} }
response = requests.post('{}/anonymize'.format(root_api_url), json=data) response = requests.post('{}/anonymize'.format(root_api_url), json=data)
print(str(detection['id']) + " Anonymized" ) print(str(detection['id']) + " Anonymized" , flush=True)
time.sleep(5) time.sleep(5)
print("sleep") print("sleep", flush=True)
time.sleep(900) time.sleep(900)
except Exception as e: except Exception as e:
print("An exception occurred") print("An exception occurred", flush=True)
print(str(e)) print(str(e), flush=True)
data = {"trace": str(e)} data = {"trace": str(e)}
response = requests.post('{}/log'.format(root_api_url), json=data) response = requests.post('{}/log'.format(root_api_url), json=data)