Fixes
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ FROM python:3.9-slim
|
|||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
# Install any needed dependencies specified in requirements.txt
|
# Install any needed dependencies specified in requirements.txt
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||||
|
|
||||||
# Start Anonimization
|
# Start Anonimization
|
||||||
CMD ["python", "app.py"]
|
CMD ["python", "app.py"]
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# VMS - Český Krumlov - Anonymizer
|
||||||
|
|
||||||
|
#### Docker Build - Powershell (One Line)
|
||||||
|
```powershell
|
||||||
|
$tag = ("0.0.1").Trim(); git reset --hard; git pull origin master; git tag $tag; git push --tags; docker build -t git.steelants.cz/steelants/py_ck:$tag .; docker push git.steelants.cz/steelants/py_ck:$tag; docker build -t git.steelants.cz/steelants/py_ck:latest .; docker push git.steelants.cz/steelants/py_ck:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Docker Build - Bash (One Line)
|
||||||
|
```bash
|
||||||
|
export TAG="0.0.1" && 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
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
ck-anonym:
|
||||||
|
image: git.steelants.cz/steelants/lar_py:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
API_ROOT: http://ck:8080
|
||||||
|
FACE_TRASHOLD: 0.5
|
||||||
|
volumes:
|
||||||
|
- ${PWD}/app_data/:/app/data/
|
||||||
|
networks: {}
|
||||||
|
```
|
||||||
@@ -2,18 +2,25 @@ import cv2
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
treashold = float(os.getenv('FACE_TRASHOLD', '0,5'))
|
treashold = float(os.getenv('FACE_TRASHOLD', '0.5'))
|
||||||
sever = os.getenv('API_ROOT', 'localhost')
|
sever = os.getenv('API_ROOT', 'localhost:8000')
|
||||||
root_api_url = 'http://{}/local'.format(sever)
|
root_api_url = 'http://{}/local'.format(sever)
|
||||||
|
|
||||||
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')
|
||||||
|
response = r.json()
|
||||||
|
|
||||||
|
for detection in response:
|
||||||
|
img_path = "/data/{}".format(detection['source_image_path'])
|
||||||
|
|
||||||
|
#Skip Non existing files
|
||||||
|
if (not os.path.exists(img_path)):
|
||||||
|
continue
|
||||||
|
|
||||||
for detection in r.json():
|
|
||||||
img_path = "/data/{}".format(detection.source_image_path)
|
|
||||||
img = cv2.imread(img_path)
|
img = cv2.imread(img_path)
|
||||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||||
faces, rejects, weights = face_cascade.detectMultiScale3(gray, 1.1, 4, outputRejectLevels = 1)
|
faces, rejects, weights = face_cascade.detectMultiScale3(gray, 1.1, 4, outputRejectLevels = 1)
|
||||||
@@ -38,14 +45,14 @@ try:
|
|||||||
cv2.imwrite(new_img_path, img)
|
cv2.imwrite(new_img_path, img)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"id": detection.id,
|
"id": detection['id'],
|
||||||
"source_image_path": new_img_path
|
"source_image_path": new_img_path
|
||||||
}
|
}
|
||||||
response = requests.post('{}/anonymize'.format(root_api_url), json=data)
|
response = requests.post('{}/anonymize'.format(root_api_url), json=data)
|
||||||
|
|
||||||
time.sleep(3)
|
time.sleep(900)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An exception occurred")
|
print("An exception occurred")
|
||||||
data = {"trace": e.__traceback__,}
|
data = {"trace": str(e)}
|
||||||
response = requests.post('{}/log'.format(root_api_url), json=data)
|
response = requests.post('{}/log'.format(root_api_url), json=data)
|
||||||
Reference in New Issue
Block a user