From 83dd9333953cd4e4cfe1a1d947af33d96baccc2b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:00:01 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- model_optimization.py | 9 +++++++-- test_face_recognition.py | 15 +++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/model_optimization.py b/model_optimization.py index 5c4f18f..31cb541 100644 --- a/model_optimization.py +++ b/model_optimization.py @@ -1,12 +1,16 @@ +import numpy as np from tensorflow.keras.applications import MobileNetV2 from tensorflow.keras.preprocessing.image import img_to_array, load_img -import numpy as np + def load_optimized_model(): - model = MobileNetV2(weights='imagenet', include_top=False, input_shape=(224, 224, 3)) + model = MobileNetV2( + weights="imagenet", include_top=False, input_shape=(224, 224, 3) + ) print("Loaded MobileNetV2 model for optimized face detection.") return model + def preprocess_image(image_path): image = load_img(image_path, target_size=(224, 224)) image = img_to_array(image) @@ -14,6 +18,7 @@ def preprocess_image(image_path): image = np.expand_dims(image, axis=0) return image + # Example usage if __name__ == "__main__": model = load_optimized_model() diff --git a/test_face_recognition.py b/test_face_recognition.py index 4d9973f..bd9ae64 100644 --- a/test_face_recognition.py +++ b/test_face_recognition.py @@ -1,20 +1,27 @@ import unittest + from face_recognition_module import detect_faces, generate_embeddings + class TestFaceRecognition(unittest.TestCase): def test_detect_faces(self): # Test with a sample image image_path = "test_images/sample.jpg" faces = detect_faces(image_path) - self.assertGreater(len(faces), 0, "No faces detected in the sample image.") + self.assertGreater( + len(faces), 0, "No faces detected in the sample image.") def test_generate_embeddings(self): # Test with a dummy face data face_data = "sample_face_data" embedding = generate_embeddings(face_data) - self.assertIsNotNone(embedding, "Embedding generation failed for the given face data.") - self.assertEqual(len(embedding), 128, "Embedding length should be 128 dimensions.") # Example dimension + self.assertIsNotNone( + embedding, "Embedding generation failed for the given face data." + ) + self.assertEqual( + len(embedding), 128, "Embedding length should be 128 dimensions." + ) # Example dimension + if __name__ == "__main__": unittest.main() -