Skip to content

Commit

Permalink
Fixed pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Iván de Paz committed Oct 8, 2024
1 parent 05d1f4e commit 1c780d4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion mtcnn/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@
# SOFTWARE.

__version__ = "1.0.0"

1 change: 0 additions & 1 deletion mtcnn/stages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@ def __call__(self, *args, **kwargs):
Raises:
NotImplementedError: If the method is not implemented in a subclass.
"""
pass
2 changes: 1 addition & 1 deletion mtcnn/utils/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]))


Expand Down
2 changes: 1 addition & 1 deletion mtcnn/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion tests/test_mtcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 1c780d4

Please sign in to comment.