-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
183d759
commit ff76845
Showing
21 changed files
with
416 additions
and
126 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
from django.contrib import admin | ||
|
||
from .config import ConfigAdmin # noqa | ||
from .deduplicationset import DeduplicationSetAdmin # noqa | ||
from .duplicate import DuplicateAdmin # noqa | ||
from .hdetoken import HDETokenAdmin # noqa | ||
from .image import ImageAdmin # noqa | ||
|
||
admin.site.site_header = "HOPE Dedup Engine" | ||
admin.site.site_title = "HOPE Deduplication Admin" | ||
admin.site.index_title = "Welcome to the HOPE Deduplication Engine Admin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/hope_dedup_engine/apps/api/config_settings_schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"detection": { | ||
"type": "object", | ||
"properties": { | ||
"confidence": { | ||
"type": "number", | ||
"exclusiveMinimum": 0, | ||
"maximum": 1, | ||
"default": "constance.config.FACE_DETECTION_CONFIDENCE" | ||
} | ||
}, | ||
"default": {}, | ||
"required": [ | ||
"confidence" | ||
] | ||
}, | ||
"recognition": { | ||
"type": "object", | ||
"properties": { | ||
"num_jitters": { | ||
"type": "integer", | ||
"minimum": 1, | ||
"default": "constance.config.FACE_ENCODINGS_NUM_JITTERS" | ||
}, | ||
"model": { | ||
"type": "string", | ||
"enum": [ | ||
"small", | ||
"large" | ||
], | ||
"default": "constance.config.FACE_ENCODINGS_MODEL" | ||
}, | ||
"preprocessors": { | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"enum": [] | ||
}, | ||
"uniquItems": true, | ||
"default": [] | ||
} | ||
}, | ||
"default": {}, | ||
"required": [ | ||
"num_jitters", | ||
"model" | ||
] | ||
}, | ||
"duplicates": { | ||
"type": "object", | ||
"properties": { | ||
"tolerance": { | ||
"type": "number", | ||
"exclusiveMinimum": 0, | ||
"maximum": 1, | ||
"default": "constance.config.FACE_DISTANCE_THRESHOLD" | ||
} | ||
}, | ||
"default": {}, | ||
"required": [ | ||
"tolerance" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"detection", | ||
"recognition", | ||
"duplicates" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from typing import Any, Literal, TypedDict | ||
|
||
from constance import config as constance_cfg | ||
|
||
from hope_dedup_engine.apps.api.models import Config | ||
|
||
|
||
class DetectionConfig(TypedDict): | ||
dnn_files_source: str | ||
dnn_backend: int | ||
dnn_target: int | ||
blob_from_image_scale_factor: float | ||
blob_from_image_mean_values: str | ||
confidence: float | ||
nms_threshold: float | ||
|
||
|
||
class RecognitionConfig(TypedDict): | ||
num_jitters: int | ||
model: Literal["small", "large"] | ||
preprocessors: list[str] | ||
|
||
|
||
class DuplicatesConfig(TypedDict): | ||
tolerance: float | ||
|
||
|
||
class ConfigDefaults(TypedDict): | ||
detection: DetectionConfig | ||
recognition: RecognitionConfig | ||
duplicates: DuplicatesConfig | ||
|
||
|
||
def get_config(config: Config | None = None) -> dict[str, Any]: | ||
DEFAULT: ConfigDefaults = { | ||
"detection": { | ||
"dnn_files_source": constance_cfg.DNN_FILES_SOURCE, | ||
"dnn_backend": constance_cfg.DNN_BACKEND, | ||
"dnn_target": constance_cfg.DNN_TARGET, | ||
"blob_from_image_scale_factor": constance_cfg.BLOB_FROM_IMAGE_SCALE_FACTOR, | ||
"blob_from_image_mean_values": constance_cfg.BLOB_FROM_IMAGE_MEAN_VALUES, | ||
"confidence": constance_cfg.FACE_DETECTION_CONFIDENCE, | ||
"nms_threshold": constance_cfg.NMS_THRESHOLD, | ||
}, | ||
"recognition": { | ||
"num_jitters": constance_cfg.FACE_ENCODINGS_NUM_JITTERS, | ||
"model": constance_cfg.FACE_ENCODINGS_MODEL, | ||
"preprocessors": [], | ||
}, | ||
"duplicates": { | ||
"tolerance": constance_cfg.FACE_DISTANCE_THRESHOLD, | ||
}, | ||
} | ||
config_settings = {} | ||
|
||
for section, defaults in DEFAULT.items(): | ||
section_settings = defaults.copy() | ||
if config and config.settings: | ||
section_settings.update(config.settings.get(section, {})) | ||
config_settings[section] = section_settings | ||
|
||
return config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django import forms | ||
|
||
from django_svelte_jsoneditor.widgets import SvelteJSONEditorWidget | ||
|
||
|
||
class EditSchemaForm(forms.Form): | ||
schema = forms.JSONField(widget=SvelteJSONEditorWidget()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.