-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vector_search function for pipeline aggregation (#30)
* Add vector_search function for pipeline aggregation * Added Vector search * chore: Add error handling for no match found in face recognition * Refactor face recognition code to use Facenet512 model for better accuracy * chore: Add tests for recognizing faces with no match found * feat: Add test for vector search functionality
- Loading branch information
Showing
7 changed files
with
725 additions
and
238 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 was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import base64 | ||
import logging | ||
from unittest.mock import MagicMock, patch | ||
|
||
|
||
import pytest | ||
from fastapi.testclient import TestClient | ||
|
||
from API.database import Database | ||
from API.route import router | ||
from API.utils import init_logging_config | ||
|
||
init_logging_config() | ||
|
||
def test_vector_search(): | ||
mock_result = [ | ||
{ | ||
"Name": "Test1", | ||
"Image": "encoded_string1", | ||
"score": 0.8 | ||
}, | ||
{ | ||
"Name": "Test2", | ||
"Image": "encoded_string2", | ||
"score": 0.7 | ||
} | ||
] | ||
|
||
mock_vector_search = MagicMock(return_value=mock_result) | ||
|
||
with patch("API.database.Database.vector_search", mock_vector_search): | ||
embedding = [0.1, 0.2, 0.3] | ||
result = Database.vector_search("collection_name", embedding) | ||
|
||
assert result == mock_result | ||
mock_vector_search.assert_called_once_with("collection_name", embedding) |
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