mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-07 02:18:07 +01:00
Embeddings normalization fixes (#14284)
* Use cosine distance metric for vec tables * Only apply normalization to multi modal searches * Catch possible edge case in stddev calc * Use sigmoid function for normalization for multi modal searches only * Ensure we get model state on initial page load * Only save stats for multi modal searches and only use cosine similarity for image -> image search
This commit is contained in:
@@ -20,10 +20,11 @@ class ZScoreNormalization:
|
||||
|
||||
@property
|
||||
def stddev(self):
|
||||
return math.sqrt(self.variance)
|
||||
return math.sqrt(self.variance) if self.variance > 0 else 0.0
|
||||
|
||||
def normalize(self, distances: list[float]):
|
||||
self._update(distances)
|
||||
def normalize(self, distances: list[float], save_stats: bool):
|
||||
if save_stats:
|
||||
self._update(distances)
|
||||
if self.stddev == 0:
|
||||
return distances
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user