Compare commits
9
Commits
0.0.4
...
new-traffiq
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38e13d94dd | ||
|
|
d4a5bc5476 | ||
|
|
d9bdc50cf1 | ||
|
|
1d3a752df1 | ||
|
|
10e9b33a99 | ||
|
|
6b99a88fab | ||
|
|
9024c75e19 | ||
|
|
e1af934979 | ||
|
|
fb17d6185f |
+3
-2
@@ -1,12 +1,13 @@
|
|||||||
# Use PHP with Apache as the base image
|
# Use PHP with Apache as the base image
|
||||||
FROM python:latest
|
FROM python:3.9
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
# Install Additional System Dependencies
|
# Install Additional System Dependencies
|
||||||
RUN apt-get update && apt-get upgrade -y
|
RUN apt-get update && apt-get upgrade -y
|
||||||
RUN apt-get install -y \
|
RUN apt-get install -y \
|
||||||
libgl1
|
libgl1 \
|
||||||
|
nano
|
||||||
|
|
||||||
# Clear cache
|
# Clear cache
|
||||||
RUN apt-get autoremove
|
RUN apt-get autoremove
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ $tag = ("0.0.4").Trim(); git reset --hard; git pull origin master; git tag $tag;
|
|||||||
|
|
||||||
#### Docker Build - Bash (One Line)
|
#### Docker Build - Bash (One Line)
|
||||||
```bash
|
```bash
|
||||||
export TAG="0.0.4" && sudo docker build -t git.steelants.cz/steelants/py_ck:"$TAG" . && sudo docker push git.steelants.cz/steelants/py_ck:"$TAG" && sudo docker build -t git.steelants.cz/steelants/py_ck:latest . && sudo docker push git.steelants.cz/steelants/py_ck:latest
|
export TAG="0.0.5" && sudo docker build -t git.steelants.cz/steelants/py_ck:"$TAG" . && sudo docker push git.steelants.cz/steelants/py_ck:"$TAG" && sudo docker build -t git.steelants.cz/steelants/py_ck:latest . && sudo docker push git.steelants.cz/steelants/py_ck:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Docker Stack Setup
|
#### Docker Stack Setup
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
ck-anonym:
|
ck-anonym:
|
||||||
image: git.steelants.cz/steelants/lar_py:latest
|
image: git.steelants.cz/steelants/py_ck:latest
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
API_ROOT: http://ck:8080
|
API_ROOT: http://ck:8080
|
||||||
|
|||||||
@@ -3,21 +3,39 @@ import time
|
|||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
import gc
|
||||||
|
import shutil
|
||||||
|
|
||||||
from retinaface import RetinaFace
|
from retinaface import RetinaFace
|
||||||
|
|
||||||
treashold = float(os.getenv('FACE_TRASHOLD', '0.9'))
|
treashold = float(os.getenv('FACE_TRASHOLD', '0.9'))
|
||||||
sever = os.getenv('API_ROOT', 'localhost:8000')
|
sever = os.getenv('API_ROOT', 'localhost:8000')
|
||||||
|
disk_treashold = os.getenv('DISK_FREE_TRASHOLD', 10)
|
||||||
|
|
||||||
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), flush=True)
|
print("API_ROOT: " + str(root_api_url), flush=True)
|
||||||
print("FACE_TRASHOLD: " + str(treashold), flush=True)
|
print("FACE_TRASHOLD: " + str(treashold), flush=True)
|
||||||
|
print("DISK_FREE_TRASHOLD: " + str(disk_treashold), flush=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
print("LOOP Started !!!", flush=True)
|
print("LOOP Started !!!", flush=True)
|
||||||
|
|
||||||
|
#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):
|
||||||
|
break
|
||||||
|
|
||||||
|
data = {"trace": "not enought free space at destination" + str(base_path) + " trashold is: " + str(disk_treashold) + "%"}
|
||||||
|
response = requests.post('{}/log'.format(root_api_url), json=data)
|
||||||
|
|
||||||
|
print("sleep", flush=True)
|
||||||
|
time.sleep(900)
|
||||||
|
|
||||||
|
# Load Records to be anonimized
|
||||||
r = requests.get('{}/anonymize'.format(root_api_url))
|
r = requests.get('{}/anonymize'.format(root_api_url))
|
||||||
# print(r.text, flush=True)
|
# print(r.text, flush=True)
|
||||||
response = r.json()
|
response = r.json()
|
||||||
@@ -25,7 +43,7 @@ try:
|
|||||||
for detection in response:
|
for detection in response:
|
||||||
print(str(detection['id']) + " Anonymization Started", flush=True)
|
print(str(detection['id']) + " Anonymization Started", flush=True)
|
||||||
|
|
||||||
img_path = "{}{}".format(base_path, detection['source_image_path'])
|
img_path = "{}{}".format(base_path, detection['path'])
|
||||||
#print(img_path, flush=True)
|
#print(img_path, flush=True)
|
||||||
#Skip Non existing files
|
#Skip Non existing files
|
||||||
if (not os.path.exists(img_path)):
|
if (not os.path.exists(img_path)):
|
||||||
@@ -39,7 +57,7 @@ try:
|
|||||||
if (len(faces) <= 0):
|
if (len(faces) <= 0):
|
||||||
data = {
|
data = {
|
||||||
"id": detection['id'],
|
"id": detection['id'],
|
||||||
"source_image_path": img_path.replace(base_path,""),
|
"path": img_path.replace(base_path,""),
|
||||||
"face_found": 0,
|
"face_found": 0,
|
||||||
}
|
}
|
||||||
response = requests.post('{}/anonymize'.format(root_api_url), json=data)
|
response = requests.post('{}/anonymize'.format(root_api_url), json=data)
|
||||||
@@ -75,15 +93,17 @@ try:
|
|||||||
|
|
||||||
data = {
|
data = {
|
||||||
"id": detection['id'],
|
"id": detection['id'],
|
||||||
"source_image_path": new_img_path.replace(base_path,""),
|
"path": new_img_path.replace(base_path,""),
|
||||||
"face_found": len(faces),
|
"face_found": len(faces),
|
||||||
}
|
}
|
||||||
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" , flush=True)
|
print(str(detection['id']) + " Anonymized" , flush=True)
|
||||||
time.sleep(10)
|
time.sleep(5)
|
||||||
|
|
||||||
|
print("Clearing Memory", flush=True)
|
||||||
|
gc.collect()
|
||||||
print("sleep", flush=True)
|
print("sleep", flush=True)
|
||||||
time.sleep(900)
|
time.sleep(300)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An exception occurred", flush=True)
|
print("An exception occurred", flush=True)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
opencv-python
|
opencv-python
|
||||||
|
requests
|
||||||
numpy
|
numpy
|
||||||
requests
|
requests
|
||||||
retina-face
|
retina-face
|
||||||
|
|||||||
Reference in New Issue
Block a user