Now supports node style config
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
f34861421c
commit
8b94fc1a94
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.env
|
.env
|
||||||
|
node_modules
|
||||||
|
@ -2,14 +2,14 @@ version: '3.1'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
photos:
|
photos:
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
build: .
|
build: .
|
||||||
image: photos:latest
|
image: photos:latest
|
||||||
container_name: photos
|
container_name: ${CONTAINER}photos
|
||||||
# depends_on:
|
# depends_on:
|
||||||
# - db
|
# - db
|
||||||
restart: always
|
restart: always
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
ports:
|
ports:
|
||||||
- ${PORT}:${PORT}
|
- ${PORT}:${PORT}
|
||||||
volumes:
|
volumes:
|
||||||
|
@ -12,10 +12,16 @@ import functools
|
|||||||
from ketrface.util import *
|
from ketrface.util import *
|
||||||
from ketrface.dbscan import *
|
from ketrface.dbscan import *
|
||||||
from ketrface.db import *
|
from ketrface.db import *
|
||||||
|
from ketrface.config import *
|
||||||
|
|
||||||
html_base = '../'
|
html_base = '../'
|
||||||
db_path = '../db/photos.db'
|
db_path = '../db/photos.db'
|
||||||
|
|
||||||
|
config = read_config()
|
||||||
|
json_str = json.dumps(config, indent = 2)
|
||||||
|
print(json_str)
|
||||||
|
exit(0)
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# Switch to using DBSCAN
|
# Switch to using DBSCAN
|
||||||
#
|
#
|
||||||
@ -166,6 +172,8 @@ print(f'{len(identities)} identities seeded.')
|
|||||||
# Cluster the clusters...
|
# Cluster the clusters...
|
||||||
print('Reducing clusters via DBSCAN')
|
print('Reducing clusters via DBSCAN')
|
||||||
reduced = DBSCAN(identities, eps = MAX_CLUSTER_DISTANCE, minPts = 2)
|
reduced = DBSCAN(identities, eps = MAX_CLUSTER_DISTANCE, minPts = 2)
|
||||||
|
if len(reduced) == 0:
|
||||||
|
reduced = identities
|
||||||
# For each cluster, merge the lists of faces referenced in the cluster's
|
# For each cluster, merge the lists of faces referenced in the cluster's
|
||||||
# "faces" field, which is pointing to clusters (and not actual faces)
|
# "faces" field, which is pointing to clusters (and not actual faces)
|
||||||
for cluster in reduced:
|
for cluster in reduced:
|
||||||
|
@ -12,7 +12,7 @@ import cv2
|
|||||||
from ketrface.util import *
|
from ketrface.util import *
|
||||||
from ketrface.db import *
|
from ketrface.db import *
|
||||||
|
|
||||||
face_base = '../'
|
face_base = '/pictures/'
|
||||||
model_name = 'VGG-Face' # 'ArcFace'
|
model_name = 'VGG-Face' # 'ArcFace'
|
||||||
detector_backend = 'mtcnn' # 'retinaface'
|
detector_backend = 'mtcnn' # 'retinaface'
|
||||||
model = DeepFace.build_model(model_name)
|
model = DeepFace.build_model(model_name)
|
||||||
@ -239,7 +239,7 @@ with conn:
|
|||||||
|
|
||||||
path = f'{face_base}faces/{"{:02d}".format(faceId % 10)}'
|
path = f'{face_base}faces/{"{:02d}".format(faceId % 10)}'
|
||||||
try:
|
try:
|
||||||
os.mkdir(path)
|
os.makedirs(path)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
57
ketrface/ketrface/config.py
Normal file
57
ketrface/ketrface/config.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import os
|
||||||
|
import json
|
||||||
|
import collections
|
||||||
|
|
||||||
|
def dict_merge(dct, merge_dct):
|
||||||
|
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
|
||||||
|
updating only top-level keys, dict_merge recurses down into dicts nested
|
||||||
|
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
|
||||||
|
``dct``.
|
||||||
|
:param dct: dict onto which the merge is executed
|
||||||
|
:param merge_dct: dct merged into dct
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
for k, v in merge_dct.items():
|
||||||
|
if (k in dct and isinstance(dct[k], dict) and isinstance(merge_dct[k], dict)): #noqa
|
||||||
|
dict_merge(dct[k], merge_dct[k])
|
||||||
|
else:
|
||||||
|
dct[k] = merge_dct[k]
|
||||||
|
return dct
|
||||||
|
|
||||||
|
def read_config():
|
||||||
|
path = os.path.normpath(os.getcwd())
|
||||||
|
res = {}
|
||||||
|
file = None
|
||||||
|
while file == None:
|
||||||
|
try:
|
||||||
|
config_path = os.path.join(path, 'config', 'default.json')
|
||||||
|
print(f'Trying {config_path}')
|
||||||
|
file = open(config_path, 'r')
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
before = path
|
||||||
|
path = os.path.normpath(os.path.join(path, '..'))
|
||||||
|
if before == path:
|
||||||
|
break
|
||||||
|
|
||||||
|
if file is None:
|
||||||
|
return res
|
||||||
|
|
||||||
|
data = json.load(file)
|
||||||
|
file.close()
|
||||||
|
dict_merge(res, data)
|
||||||
|
|
||||||
|
try:
|
||||||
|
config_path = os.path.join(path, 'config', 'local.json')
|
||||||
|
file = open(config_path, 'r')
|
||||||
|
except:
|
||||||
|
file = None
|
||||||
|
|
||||||
|
if file is None:
|
||||||
|
return res
|
||||||
|
|
||||||
|
data = json.load(file)
|
||||||
|
file.close()
|
||||||
|
dict_merge(res, data)
|
||||||
|
|
||||||
|
return res
|
Loading…
x
Reference in New Issue
Block a user