diff --git a/.pylintrc b/.pylintrc index f6716c8..82eb633 100644 --- a/.pylintrc +++ b/.pylintrc @@ -296,7 +296,7 @@ ignored-parents= max-args=9 # Maximum number of attributes for a class (see R0902). -max-attributes=7 +max-attributes=18 # Maximum number of boolean expressions in an if statement (see R0916). max-bool-expr=5 @@ -441,7 +441,10 @@ disable=raw-checker-failed, deprecated-pragma, use-symbolic-message-instead, use-implicit-booleaness-not-comparison-to-string, - use-implicit-booleaness-not-comparison-to-zero + use-implicit-booleaness-not-comparison-to-zero, + no-member, + no-name-in-module + # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/mtcnn/metadata.py b/mtcnn/metadata.py index 1e52c0f..4f3196e 100644 --- a/mtcnn/metadata.py +++ b/mtcnn/metadata.py @@ -21,4 +21,3 @@ # SOFTWARE. __version__ = "1.0.0" - diff --git a/mtcnn/stages/base.py b/mtcnn/stages/base.py index 30c6d2c..b202ac8 100644 --- a/mtcnn/stages/base.py +++ b/mtcnn/stages/base.py @@ -89,4 +89,3 @@ def __call__(self, *args, **kwargs): Raises: NotImplementedError: If the method is not implemented in a subclass. """ - pass diff --git a/mtcnn/utils/images.py b/mtcnn/utils/images.py index 85be550..ffd36f2 100644 --- a/mtcnn/utils/images.py +++ b/mtcnn/utils/images.py @@ -258,7 +258,7 @@ def ensure_stack(images): images = pad_stack_np(images) # Broadcast to ensure the images have a consistent shape (batch dimension) - return np.broadcast_to(images, + return np.broadcast_to(images, [(len(images.shape) < 4) + (len(images.shape) >= 4) * images.shape[0],] + list(images.shape[len(images.shape) >= 4:])) diff --git a/mtcnn/utils/plotting.py b/mtcnn/utils/plotting.py index d9750bd..3dc6f49 100644 --- a/mtcnn/utils/plotting.py +++ b/mtcnn/utils/plotting.py @@ -167,7 +167,7 @@ def parse_color(color): int(f"{color[2]}{color[2]}", base=16)]) / 255 if len(color) == 6: # Full form hex color (#RRGGBB) color = np.asarray([int(f"{color[0]}{color[1]}", base=16), - int(f"{color[2]}{color[3]}", base=16), + int(f"{color[2]}{color[3]}", base=16), int(f"{color[4]}{color[5]}", base=16)]) / 255 return color diff --git a/tests/test_mtcnn.py b/tests/test_mtcnn.py index e191de1..1999699 100644 --- a/tests/test_mtcnn.py +++ b/tests/test_mtcnn.py @@ -47,7 +47,7 @@ def test_images(): # Cargar los bytes de las imágenes with open(valid_image_path, "rb") as f: valid_image_bytes = f.read() - + with open(no_faces_image_path, "rb") as f: no_faces_image_bytes = f.read() @@ -75,6 +75,7 @@ def test_detect_faces_from_uri(mtcnn_detector, test_images): # Check bounding box in 'xywh' format by default assert len(first['box']) == 4, "Bounding box should contain 4 coordinates (X1, Y1, width, height)." + def test_detect_faces_from_bytes(mtcnn_detector, test_images): """ Test MTCNN detects faces and landmarks when given an image as bytes. @@ -84,6 +85,7 @@ def test_detect_faces_from_bytes(mtcnn_detector, test_images): assert isinstance(result, list), "Output should be a list of bounding boxes." assert len(result) > 0, "Should detect at least one face in the image." + def test_detect_no_faces(mtcnn_detector, test_images): """ Test that MTCNN returns an empty list when no faces are detected in a valid image. @@ -92,6 +94,7 @@ def test_detect_no_faces(mtcnn_detector, test_images): assert isinstance(result, list), "Output should be a list." assert len(result) == 0, "Should detect no faces in the image." + def test_detect_faces_batch_from_uri(mtcnn_detector, test_images): """ Test batch detection when passed a list of URIs. @@ -105,6 +108,7 @@ def test_detect_faces_batch_from_uri(mtcnn_detector, test_images): assert isinstance(result[1], list), "Second result should be a list of bounding boxes." assert len(result[1]) == 0, "Second image should detect no faces." + def test_detect_faces_batch_from_bytes(mtcnn_detector, test_images): """ Test batch detection when passed a list of image byte arrays.