Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metric Engine V2 (-> feat/no-disk) #565

Merged
merged 155 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
523159b
Start
james-encord Jun 16, 2023
6cc68f5
Model definition, testing db creation
james-encord Jun 16, 2023
8eeaaf8
New API
james-encord Jun 19, 2023
7748c20
SQL queries
james-encord Jun 20, 2023
7722f17
Initial migration script
james-encord Jun 21, 2023
d9a5fa6
Partially working metric migration script
james-encord Jun 21, 2023
ce2d65d
Add partial embedding support to global db storage.
james-encord Jun 21, 2023
fdb3017
Extra search terms
james-encord Jun 21, 2023
18d25c6
Database migrations support.
james-encord Jun 21, 2023
7e853cb
Bug fixes
james-encord Jun 21, 2023
d90ebd0
Fixes from testing
james-encord Jun 21, 2023
797edf8
Misc
james-encord Jun 22, 2023
7a73f22
Migrate tags
james-encord Jun 22, 2023
9c31424
Start of new api endpoint.
james-encord Jun 22, 2023
b05ea7d
Work on storing predictions and more data quality assertions in migra…
james-encord Jun 23, 2023
d9209b0
Process predictions into db, main metadata.
james-encord Jun 23, 2023
8ad861b
Add some constraints to the database
james-encord Jun 23, 2023
66ddbdf
Cleanup of metric definitions
james-encord Jun 26, 2023
bc130c4
Improve queries
james-encord Jun 27, 2023
0353316
Bugfixes
james-encord Jun 27, 2023
2e26071
Bugfixes
james-encord Jun 28, 2023
fc899c3
Minor prediction changes.
james-encord Jun 29, 2023
974615e
Calculate prediction matches
james-encord Jun 29, 2023
be0ba02
More prediction calculation support.
james-encord Jun 29, 2023
36f537d
Start of prediction metrics support.
james-encord Jun 30, 2023
97947a1
Add metric correlations support.
james-encord Jun 30, 2023
c0b321e
Rename & unify object, classification.
james-encord Jul 3, 2023
21b48f8
Mutual info regression, WIP
james-encord Jul 3, 2023
73c3686
Embedding search & more prediction support
james-encord Jul 4, 2023
e110c06
Split new router into 3.
james-encord Jul 5, 2023
b890e30
Fix all linting.
james-encord Jul 5, 2023
6c8178d
Post-rebase regen poetry lock
james-encord Jul 5, 2023
c696034
Fix some bugs with predictions from rebase & others
james-encord Jul 5, 2023
0d82950
Bug fixes and start of prediction explorer implementation.
james-encord Jul 6, 2023
f17ffde
poetry lock fix post rebase
james-encord Jul 18, 2023
5575e8c
Support metric dissimilarity.
james-encord Jul 6, 2023
d0ddf8d
Move db migration script out as it is is needed to execute dynamicall…
james-encord Jul 6, 2023
42271ec
wip - extra formatting improvements and start of extra backend apis n…
james-encord Jul 12, 2023
d88f339
Rework stages
james-encord Jul 12, 2023
3f4df33
Re-validate predictions, now fully correct handling of FP/FN/TP split.
james-encord Jul 13, 2023
b0511cc
Optimize metric performance query.
james-encord Jul 14, 2023
979400a
Summary query filter support, part 1.
james-encord Jul 14, 2023
bb86ff8
Summary query filter support, part 2.
james-encord Jul 14, 2023
f3813af
Summary query filter support, part 3. Prediction implementation is pa…
james-encord Jul 14, 2023
69c42d5
Bug fixes for GET filter query parameters.
james-encord Jul 14, 2023
9c9eec0
Change some defaults.
james-encord Jul 17, 2023
98c08fe
wip: project2 actions
james-encord Jul 17, 2023
b6bb0d6
Re-enable reduced embedding extension storage
james-encord Jul 18, 2023
48fa926
Improve queries
james-encord Jun 27, 2023
80a77ba
feat: introduce new frontend
Encord-davids Jun 29, 2023
d3812b4
feat: adds project selector to the top right
Encord-davids Jul 6, 2023
b51163f
fix: scoped queries unique keys
Encord-davids Jul 6, 2023
fab8e2f
Backend implementation of synced create subset & upload project actions.
james-encord Jul 6, 2023
d667ae1
Update FE & Fix communication issues with legacy codebase from update…
james-encord Jul 10, 2023
e33ea40
Add upload to encord action, still have df issues with subset creation.
james-encord Jul 12, 2023
0175dd5
Pandas bug-fixes
james-encord Jul 12, 2023
ef1a0ce
feat: introduce filters UI
Encord-davids Jul 6, 2023
e93d18f
fix: project selection page
Encord-davids Jul 13, 2023
cf6bb40
fix: remove log
Encord-davids Jul 13, 2023
ad49c98
fix: project card show image
Encord-davids Jul 13, 2023
05bccf7
fix: add project hash to query keys
Encord-davids Jul 13, 2023
a18c5f6
Post rebase frontend updates & misc fixes. Partially fix migration sc…
james-encord Jul 18, 2023
3c0ebda
Update migration script to work on new formatting changes for certain…
james-encord Jul 18, 2023
54b5abb
feat: auth on new FE
Encord-davids Jul 19, 2023
5fb6480
feat: alembic migration versions.
james-encord Jul 19, 2023
35f6e86
Tag sync, alembic debugging, & re-enable proper project migration beh…
james-encord Jul 19, 2023
ff7fdfd
fix: id splitting in migration
Encord-davids Jul 20, 2023
459b461
fixdxdsxFix db unique constraint & label row hash uniqueness for loca…
james-encord Jul 20, 2023
fc72980
wip: serve FE build assets on server & migrate on startup.
james-encord Jul 20, 2023
d26cf13
WIP: adds download sandbox and disables it
Encord-davids Jul 20, 2023
f53ddb6
fix: query invalidation & improved local fs serve logic.
james-encord Jul 20, 2023
2d6fba4
fix: proper subset creation logic.
james-encord Jul 20, 2023
bb37699
fix: disable upload to encord when filters applied
james-encord Jul 20, 2023
c79de61
upload project & create subset: misc improvements / fixes.
james-encord Jul 20, 2023
b4eacf4
WIP: fe cleanup
Encord-davids Jul 20, 2023
62b4c8d
fix: predictions explorer set selected project
Encord-davids Jul 20, 2023
b8fdb05
fix: display raw images for non-sandbox projects.
james-encord Jul 20, 2023
640f173
wip - feat: filter impl improvement & first attempt at label class fi…
james-encord Jul 20, 2023
0d60917
fix: use relative url only when built.
james-encord Jul 20, 2023
1475a7f
fix: null api context edge case (rare)
james-encord Jul 20, 2023
60e7557
fix: build errors & upload to encord file path.
james-encord Jul 20, 2023
a0527bd
fix: bring back startup
Encord-davids Jul 20, 2023
6af9875
fix: filter data by label class
Encord-davids Jul 20, 2023
f9cbca6
fix fe: style & misc bugs
james-encord Jul 20, 2023
d5448a9
fix: encord upload, invalidate caches before reading updated data.
james-encord Jul 20, 2023
144f5b1
chore: rename visualize to start
Encord-davids Jul 20, 2023
574e14d
chore: change default port to 8000
Encord-davids Jul 21, 2023
15eb7a1
fix: partially working encord-active upload, issue with local data ur…
james-encord Jul 21, 2023
4b2b6f3
fix: remove scroll jitter while explorer is loading.
james-encord Jul 21, 2023
9f528f5
feat: favicon.ico
james-encord Jul 21, 2023
3340750
fix: debounce filters for perf.
james-encord Jul 21, 2023
5c7423b
chore: dev mode
Encord-davids Jul 21, 2023
ebb716a
fix: prefer relative uri - fixes upload to encord & remote subset.
james-encord Jul 21, 2023
417e53d
chore: delete app folder
Encord-davids Jul 21, 2023
05673ee
chore: replace encord-active-components with new implementation
Encord-davids Jul 21, 2023
5a29cd4
chore: kill streamlit
Encord-davids Jul 21, 2023
95fe3ac
fix: misc db schema fixes, more correct metric normalisation & misc b…
james-encord Jul 24, 2023
33b07c8
WIP: fix lintting
Encord-davids Jul 24, 2023
5363653
fix: all mypy + other lint issues.
james-encord Jul 24, 2023
620eef8
fix: ea-components dev mode & error on missing components on non-dev …
james-encord Jul 24, 2023
949f649
fix: project level statistics & ttl cache
james-encord Jul 24, 2023
98cfcaf
fix: black and isort
Encord-davids Jul 25, 2023
289d6d2
fix: project description accessor
Encord-davids Jul 25, 2023
94d6012
fix: prediction migration bug.
james-encord Jul 25, 2023
28489ac
fix: project comparison project selection
Encord-davids Jul 25, 2023
983a9e7
fix: classification predictions
james-encord Jul 25, 2023
3d1108c
fix: misc style fixes
james-encord Jul 26, 2023
c72ad42
fix: misc styling & logging on migration
james-encord Jul 26, 2023
425b806
fix: ok style for modals
james-encord Jul 26, 2023
8bc1bac
fix: prediction metrics design & buckets
james-encord Jul 26, 2023
2eeb20d
fix: prediction selection improvements & rename comparison domain to …
james-encord Jul 26, 2023
3c62118
fix: hide prediction selector while only 1 prediction is present.
james-encord Jul 26, 2023
789fcf7
fix: upload to encord error boundaries and state updates.
james-encord Jul 26, 2023
d9d3640
fix: project name and folder missmatch
Encord-davids Jul 26, 2023
1567ecc
fix: ts error
Encord-davids Jul 26, 2023
3aa5473
fix: tagging query invalidation keys
Encord-davids Jul 26, 2023
196c263
FE-side fix: generate feature hash mapping for recursive attributes.
james-encord Jul 26, 2023
1fcdbec
fix: FE quartile line overlay & naming of similarity.
james-encord Jul 26, 2023
a830b75
fix: bounding box prediction
Encord-davids Jul 26, 2023
36b2c78
fix: old predictions folder structure
Encord-davids Jul 26, 2023
4dd1bf0
wip-fix: classification prediction handling.
james-encord Jul 26, 2023
c0d78ec
fix: style project comparison.
james-encord Jul 27, 2023
4d8da2f
fix: implement legacy classification hash handling.
james-encord Jul 27, 2023
8f261f0
fix: minor fe tweaks
james-encord Jul 27, 2023
705f5e5
fix: better scaling for large prediction v-bars
james-encord Jul 27, 2023
2e34556
fix: react key errors
Encord-davids Jul 27, 2023
0bf9577
fix: duplicate metrics on predictions page
Encord-davids Jul 27, 2023
ae86ffd
delete sreamlit file
Encord-davids Jul 27, 2023
0ac7a69
fix: subset migration version and reduced embeddings
Encord-davids Jul 27, 2023
29feebf
fix: hide metric_random, handle classification annotation_quality, do…
james-encord Jul 27, 2023
ba77b46
WIP: Rework of embeddings and metrics to more abstract and computatio…
james-encord May 16, 2023
a2376e5
WIP: More proposed cleanup for metric definitions
james-encord May 22, 2023
ffce2e1
More changes
james-encord May 23, 2023
d532eb3
wip: metric refactor
frederik-encord Jun 28, 2023
31c414e
wip
frederik-encord Jul 5, 2023
891db92
james: clean-up evaluation logic for new metric logic.
james-encord Jul 17, 2023
5e9f7c3
james: Partly working metric executor engine.
james-encord Jul 18, 2023
3e5ebcb
misc fixes
james-encord Jul 18, 2023
4705ead
Many fixes, stage 1 is not partly working (mps should be commented out).
james-encord Jul 19, 2023
5bba94a
feat: finish MVP metric computation engine. Works - now need to defin…
james-encord Jul 21, 2023
1e66908
fix: misc fixes.
james-encord Jul 21, 2023
2341f4e
wip: start of batch api for metrics.
james-encord Jul 24, 2023
8da864d
Merge branch 'main' into feat/metric-restructure-3
james-encord Jul 31, 2023
2137a52
Add more metrics, 4 left to implement.
james-encord Aug 1, 2023
1d996b9
Add alembic migration.
james-encord Aug 1, 2023
5b80632
WIP: Cleanup, bug-fixes & extra verification.
james-encord Aug 1, 2023
3a5245f
fix: lint-fixes
james-encord Aug 2, 2023
2c42b0b
fix: add FIXMEs
james-encord Aug 2, 2023
211a549
nb: add more fixme
james-encord Aug 2, 2023
90f6524
fix: mypy collision
james-encord Aug 2, 2023
af248e3
fix: rename executor project_dir to database_dir
james-encord Aug 2, 2023
3b0ac24
tuning: use same exhaustive search threshold used internally by umap …
james-encord Aug 2, 2023
ae9bea0
Merge branch 'main' into feat/metric-restructure-3
james-encord Aug 4, 2023
ab7adca
fix: separate WIP migration script for metric engine.
james-encord Aug 4, 2023
6f1d681
fix: pylint
james-encord Aug 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ uvicorn = { extras = ["standard"], version = "^0.21.1" }
nodejs-bin = "^16.15.1a4"
pyjwt = "^2.7.0"
torch = "^2.0.0"
kornia = "^0.6.12"
clip-ea = "^1.0"
torchvision = "^0.15.2"
ftfy = "^6.1.1"
Expand Down Expand Up @@ -142,7 +143,7 @@ profile = "black"
plugins = "pandera.mypy"
ignore_missing_imports = true
enable_recursive_aliases = true
exclude = ['examples/', "./src/encord_active/db/migrations/.*"]
exclude = ['examples/', "./src/encord_active/db/migrations/.*", "local_tests/.*", "venv/bin/.*"]

[tool.pylint.'MASTER']
extension-pkg-allow-list = "cv2"
Expand Down
3 changes: 3 additions & 0 deletions src/encord_active/analysis/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Performance improvements

- [ ] Batch images when computing embeddings. Otherwise, we won't be able to utilize the GPU
Empty file.
166 changes: 166 additions & 0 deletions src/encord_active/analysis/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
from abc import ABC, ABCMeta, abstractmethod
from dataclasses import dataclass
from typing import Dict, Optional

from encord_active.analysis.types import (
AnnotationMetadata,
BoundingBoxBatchTensor,
FeatureHashBatchTensor,
ImageBatchTensor,
ImageIndexBatchTensor,
ImageTensor,
MaskBatchTensor,
MetricBatchDependencies,
MetricBatchResult,
MetricDependencies,
MetricResult,
)
from encord_active.db.metrics import MetricType


@dataclass(frozen=True) # FIXME: deprecate for new version
class BaseFrameInput:
image: ImageTensor
image_deps: MetricDependencies
# key is object_hash | classification_hash
annotations: Dict[str, AnnotationMetadata]
annotations_deps: Dict[str, MetricDependencies]
# hash collision, if set the object or classification hash uniqueness constraint is
# not held for this frame
hash_collision: bool


@dataclass
class BaseFrameOutput:
image: Optional[MetricResult]
annotations: Dict[str, MetricResult]


@dataclass
class BaseFrameAnnotationBatchInput:
"""
Dictionary to B x dependencies
"""

objects_masks: MaskBatchTensor
"""
O x Masks (O = SUM{i.annotation_count * B}
"""
objects_bounding_boxes: BoundingBoxBatchTensor
""""
O x Bounding Boxes
"""
objects_deps: MetricBatchDependencies
"""
dependency map to Ox<value> tensors
"""
objects_image_indices: ImageIndexBatchTensor
"""
O x int32 index to the associated image.
"""
objects_feature_hash: FeatureHashBatchTensor
"""
O x int64 converted feature hash values
"""
classifications_deps: MetricBatchDependencies
"""
dependency map to Cx<value> tensors
"""
classifications_image_indices: ImageIndexBatchTensor
"""
C x int32 index to the associated image.
"""
classifications_feature_hash: FeatureHashBatchTensor
"""
C x int64 converted feature hash values
"""


@dataclass
class BaseFrameBatchInput:
images: ImageBatchTensor
"""
B x image tensors
"""
images_deps: MetricBatchDependencies
"""
Dictionary to B x dependencies
"""
annotations: Optional[BaseFrameAnnotationBatchInput]
"""
All annotation batches associated with this image batch.
Values are split into classifications & objects (objects have masks + aabb)
"""


@dataclass
class BaseFrameBatchOutput:
images: Optional[MetricBatchResult]
"""
B x image results
"""
objects: Optional[MetricBatchResult]
"""
O x annotation results
"""
classifications: Optional[MetricBatchResult]
"""
C x classification results
"""


class BaseEvaluation(ABC):
"""
Base evaluations are the most abstract definitions of computations that need to happen.
They can be both:

- Quality Metrics that needs to be stored (The `BaseAnalysis` subclass)
- Computations the need to happen for Quality Metrics to be able to share computations.
For example, Embeddings, image transforms, etc.

"""

def __init__(self, ident: str) -> None:
self.ident = ident

@abstractmethod
def raw_calculate(
self,
prev_frame: Optional[BaseFrameInput],
frame: BaseFrameInput,
next_frame: Optional[BaseFrameInput],
) -> BaseFrameOutput:
"""
Base implementation of the raw_calculate method, this api should
be considered unstable.
"""
...

@abstractmethod
def raw_calculate_batch(
self,
prev_frame: Optional[BaseFrameBatchInput],
frame: BaseFrameBatchInput,
next_frame: Optional[BaseFrameBatchInput],
) -> BaseFrameBatchOutput:
"""
Base implementation of batched metric calculation.
"""


class BaseAnalysis(BaseEvaluation, metaclass=ABCMeta):
"""
The `BaseAnalysis` is all the metrics that needs to be stored in the
database.
"""

def __init__(self, ident: str, long_name: str, desc: str) -> None:
super().__init__(ident)
self.long_name = long_name
self.desc = desc


class BaseMetric(BaseAnalysis, metaclass=ABCMeta):
def __init__(self, ident: str, long_name: str, desc: str, metric_type: MetricType) -> None:
super().__init__(ident, long_name, desc)
self.metric_type = metric_type
171 changes: 171 additions & 0 deletions src/encord_active/analysis/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
import os
from typing import Union

import torch

from .base import BaseEvaluation
from .conversions.grayscale import RGBToGray
from .conversions.hsv import RGBToHSV
from .embedding import NearestImageEmbeddingQuery
from .embeddings.clip import ClipImgEmbedding
from .embeddings.hu_moment import HuMomentEmbeddings
from .metric import DerivedMetric, RandomSamplingQuery
from .metrics.active_learning.uniqueness import ImageUniqueness
from .metrics.annotation.count import ObjectCountMetric
from .metrics.annotation.density import ObjectDensityMetric
from .metrics.annotation.distance_to_border import DistanceToBorderMetric
from .metrics.annotation.maximum_label_iou import MaximumLabelIOUMetric
from .metrics.annotation.nearest_neighbor_agreement import NearestNeighborAgreement
from .metrics.image.area import AreaMetric, AreaRelativeMetric
from .metrics.image.aspect_ratio import AspectRatioMetric
from .metrics.image.brightness import BrightnessMetric
from .metrics.image.colors import HSVColorMetric
from .metrics.image.contrast import ContrastMetric
from .metrics.image.height import HeightMetric
from .metrics.image.random_value import RandomMetric
from .metrics.image.sharpness import SharpnessMetric
from .metrics.image.width import WidthMetric

"""
Operations to support tracking for:
1. Add new input (image/video/...):
- calculate new data
- invalidate nearby embeddings
2. Delete input
- cascade delete data
- invalidate nearby embeddings
3. Add object
- see new input
- calculate new data
- invalidate nearby embeddings
4. Update object
- internally implement as delete + add (as 1 transaction in db state)
5. Delete object
- see new output
- cascade delete data
- invalidate nearby embeddings
"""


class AnalysisConfig:
"""
Config for the complete analysis state.
This should be generated once and re-used for all metric analysis
Based upon the results.
"""

def __init__(
self,
analysis: list[BaseEvaluation],
derived_embeddings: list[Union[NearestImageEmbeddingQuery, RandomSamplingQuery]],
derived_metrics: list[DerivedMetric],
device: torch.device,
) -> None:
"""
Args:
analysis:
List of pure analysis that only depend on the input state, or
earlier analysis results in the list. This can generate
temporary tensors, embeddings and metrics.
derive_embeddings:
List of embeddings based properties that are derived from input embeddings,
all operations:
- Nearest Embedding
- Nearest N Embeddings (where N is hardcoded constant).
derive_metrics:
List of metrics that only take exported results from earlier analysis and
derived_embedding results.
"""
self.analysis = analysis
self.derived_embeddings = derived_embeddings
self.derived_metrics = derived_metrics
self.device = device

def validate(self) -> None:
"""
Asserts that the given analysis config is valid for execution.
"""
...

def analysis_versions(self) -> dict[str, int]:
"""
Returns:
The version for each exported metric or embedding,
this value should be incremented whenever the code
is changed in a way that would result in different results
being returned if the function were to be re-executed.
Exported features missing
"""
...


def default_torch_device() -> torch.device:
"""Default torch device to use for the analysis config"""
torch_device_str = "cpu"
# FIXME: currently CPU only due to GPU being too slow due to lack of batch support.
# keep this until batch functions are properly implemented.
if torch.cuda.is_available() and os.environ.get("ACTIVE_ALLOW_TORCH_CUDA_BACKEND", "0") == "1":
torch_device_str = "cuda"
elif torch.backends.mps.is_available() and os.environ.get("ACTIVE_ALLOW_TORCH_MPS_BACKEND", "0") == "1":
torch_device_str = "mps"
return torch.device(torch_device_str)


def create_analysis(device: torch.device) -> AnalysisConfig:
"""List of all analysis passes to be executed by encord active"""
analysis: list[BaseEvaluation] = [
# Generate embeddings
ClipImgEmbedding(device, "embedding_clip", "ViT-B/32"),
HuMomentEmbeddings(),
# FIXME: HuMomentEmbeddings("embedding_hu_moments"),
# Image transformations
RGBToHSV(),
RGBToGray(),
# Unified Image or Annotation Feature Metrics
AspectRatioMetric(), # metric_aspect_ratio
AreaMetric(), # metric_area
BrightnessMetric(), # metric_brightness
ContrastMetric(), # metric_contrast
SharpnessMetric(), # metric_sharpness
HSVColorMetric("red", hue_query=0.0), # metric_red
HSVColorMetric("green", hue_query=1 / 3.0), # metric_green
HSVColorMetric("blue", hue_query=2 / 3.0), # metric_blue
HeightMetric(), # metric_height
WidthMetric(), # metric_width
RandomMetric(), # metric_random
# Annotation only metrics
AreaRelativeMetric(), # metric_area_relative
MaximumLabelIOUMetric(), # metric_max_iou
DistanceToBorderMetric(), # metric_label_border_closeness
# Annotation based Frame Metrics
ObjectCountMetric(), # metric_object_count
ObjectDensityMetric(), # metric_object_density ("Frame object density")
# ?????
# FIXME: metric_image_difficulty ("Image Difficulty") FIXME: KMeans!!??
# FIXME: metric_label_inconsistent_classification_and_track ("Inconsistent Object Classification and Track IDs")
# FIXME: metric_label_shape_outlier ("Shape outlier detection")
# FIXME: metric_seq_occlusion_detection (ALSO - MISSING COLUMN NAME, WILL NEED ALEMBIC MIGRATION)
# Temporal metrics
# FIXME: DISABLED TemporalShapeChange(), # metric_label_poly_similarity ("Polygon Shape Similarity")
# FIXME: DISABLED TemporalMissingObjectsAndWrongTracks(), # metric_label_missing_or_broken_tracks ("Missing Objects and Broken Tracks")
]
derived_embeddings: list[Union[NearestImageEmbeddingQuery, RandomSamplingQuery]] = [
# Derive properties from embedding
NearestImageEmbeddingQuery("derived_clip_nearest", "embedding_clip"),
]
derived_metrics: list[DerivedMetric] = [
# Metrics depending on derived embedding / metric properties ONLY
NearestNeighborAgreement(), # metric_annotation_quality
ImageUniqueness(), # metric_image_uniqueness ("Image Singularity")
]
return AnalysisConfig(
analysis=analysis,
# FIXME?: derived_temporal (derived metrics that have access to analysis values in N frame range)
derived_embeddings=derived_embeddings,
derived_metrics=derived_metrics,
device=device,
)


def get_default_analysis():
analysis = create_analysis(torch.device("cpu"))
Loading