-
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
3bebe7b
commit ce25f45
Showing
4 changed files
with
91 additions
and
103 deletions.
There are no files selected for viewing
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
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,37 +1,28 @@ | ||
from collections.abc import Iterable | ||
from enum import Enum | ||
from typing import Self | ||
from typing import TYPE_CHECKING, Self | ||
|
||
# from hope_dedup_engine.constants import FacialError | ||
# TODO: | ||
# from hope_dedup_engine.apps.api.models.deduplication import Finding as FindingModel | ||
if TYPE_CHECKING: | ||
from hope_dedup_engine.apps.api.models.deduplication import ( # noqa: F401 | ||
Finding as FindingModel, | ||
) | ||
|
||
# .Image import StatusCode | ||
|
||
type ReferencePK = str | ||
type Filename = str | ||
type Embedding = list[float] | ||
type Score = float | ||
|
||
|
||
class FacialError(Enum): | ||
GENERIC_ERROR = 999 | ||
NO_FACE_DETECTED = 998 | ||
MULTIPLE_FACES_DETECTED = 997 | ||
NO_FILE_FOUND = 996 | ||
|
||
|
||
EntityImage = tuple[ReferencePK, Filename] | ||
EntityEmbedding = tuple[ReferencePK, Embedding] | ||
EntityEmbeddingError = tuple[ReferencePK, FacialError] | ||
EntityEmbeddingError = tuple[ReferencePK, "FindingModel.StatusCode"] | ||
ImageEmbedding = tuple[Filename, Embedding] | ||
ImageEmbeddingError = tuple[Filename, FacialError] | ||
Finding = tuple[ReferencePK, ReferencePK, Score] | ||
ImageEmbeddingError = tuple[Filename, "FindingModel.StatusCode"] | ||
|
||
|
||
class SortedTuple(tuple): | ||
def __new__(cls, iterable: Iterable) -> Self: | ||
return tuple.__new__(cls, sorted(iterable)) | ||
|
||
|
||
IgnoredPair = SortedTuple[ReferencePK, ReferencePK] | ||
EntityIgnoredPair = SortedTuple[ReferencePK, ReferencePK] |