From d554630534e9bcd286ea4790da3d9119c9054002 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Sun, 13 Oct 2024 16:49:24 -0400 Subject: [PATCH 1/3] set minScore correctly --- machine-learning/locustfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine-learning/locustfile.py b/machine-learning/locustfile.py index 81087bee8c923..7bf8c3909d5a9 100644 --- a/machine-learning/locustfile.py +++ b/machine-learning/locustfile.py @@ -74,10 +74,10 @@ def recognize(self) -> None: "facial-recognition": { "recognition": { "modelName": self.environment.parsed_options.face_model, - "options": {"minScore": self.environment.parsed_options.face_min_score}, }, "detection": { "modelName": self.environment.parsed_options.face_model, + "options": {"minScore": self.environment.parsed_options.face_min_score}, }, } } From 662b0f844aa7c6e139458655c04f053082802da4 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:16:30 -0400 Subject: [PATCH 2/3] cleanup --- .../app/models/facial_recognition/recognition.py | 3 +-- machine-learning/app/test_main.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/machine-learning/app/models/facial_recognition/recognition.py b/machine-learning/app/models/facial_recognition/recognition.py index c060bdd61634f..574411f3902e9 100644 --- a/machine-learning/app/models/facial_recognition/recognition.py +++ b/machine-learning/app/models/facial_recognition/recognition.py @@ -19,9 +19,8 @@ class FaceRecognizer(InferenceModel): depends = [(ModelType.DETECTION, ModelTask.FACIAL_RECOGNITION)] identity = (ModelType.RECOGNITION, ModelTask.FACIAL_RECOGNITION) - def __init__(self, model_name: str, min_score: float = 0.7, **model_kwargs: Any) -> None: + def __init__(self, model_name: str, **model_kwargs: Any) -> None: super().__init__(model_name, **model_kwargs) - self.min_score = model_kwargs.pop("minScore", min_score) self.batch = self.model_format == ModelFormat.ONNX def _load(self) -> ModelSession: diff --git a/machine-learning/app/test_main.py b/machine-learning/app/test_main.py index ad8986d57240b..660cadace27f2 100644 --- a/machine-learning/app/test_main.py +++ b/machine-learning/app/test_main.py @@ -323,7 +323,7 @@ def test_run(self, ann_session: mock.Mock, mocker: MockerFixture) -> None: session.run(None, input_feed) ann_session.return_value.execute.assert_called_once_with(123, [input1, input2]) - np_spy.call_count == 2 + assert np_spy.call_count == 2 np_spy.assert_has_calls([mock.call(input1), mock.call(input2)]) @@ -456,11 +456,14 @@ def test_mclip_tokenizer( class TestFaceRecognition: - def test_set_min_score(self, mocker: MockerFixture) -> None: - mocker.patch.object(FaceRecognizer, "load") - face_recognizer = FaceRecognizer("buffalo_s", cache_dir="test_cache", min_score=0.5) + def test_set_min_score(self, snapshot_download: mock.Mock, ort_session: mock.Mock, path: mock.Mock) -> None: + path.return_value.__truediv__.return_value.__truediv__.return_value.suffix = ".onnx" + + face_detector = FaceDetector("buffalo_s", min_score=0.5, cache_dir="test_cache") + face_detector.load() - assert face_recognizer.min_score == 0.5 + assert face_detector.min_score == 0.5 + assert face_detector.model.det_thresh == 0.5 def test_detection(self, cv_image: cv2.Mat, mocker: MockerFixture) -> None: mocker.patch.object(FaceDetector, "load") From d151c08fde5c3162d1bac5e252881b702d6d166d Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:35:26 -0400 Subject: [PATCH 3/3] remove outdated tag score --- machine-learning/locustfile.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/machine-learning/locustfile.py b/machine-learning/locustfile.py index 7bf8c3909d5a9..9a07a99688a98 100644 --- a/machine-learning/locustfile.py +++ b/machine-learning/locustfile.py @@ -14,12 +14,6 @@ def _(parser: ArgumentParser) -> None: parser.add_argument("--clip-model", type=str, default="ViT-B-32::openai") parser.add_argument("--face-model", type=str, default="buffalo_l") - parser.add_argument( - "--tag-min-score", - type=int, - default=0.0, - help="Returns all tags at or above this score. The default returns all tags.", - ) parser.add_argument( "--face-min-score", type=int,