Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 28, 2024
1 parent d0884e1 commit 83dd933
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 7 additions & 2 deletions model_optimization.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
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)
image = image / 255.0 # Normalize image
image = np.expand_dims(image, axis=0)
return image


# Example usage
if __name__ == "__main__":
model = load_optimized_model()
Expand Down
15 changes: 11 additions & 4 deletions test_face_recognition.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 83dd933

Please sign in to comment.