From 17e567dc0b7acc77acb857e7a3b08793062822a3 Mon Sep 17 00:00:00 2001 From: patlevin Date: Mon, 13 May 2024 23:25:04 +0200 Subject: [PATCH] update dependency to Pillow 10.3.0, fixes #13 --- LICENSE | 2 +- docs/example-explained.md | 2 +- fdlite/__init__.py | 2 +- fdlite/transform.py | 12 ++++++------ setup.cfg | 6 +++--- setup.py | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/LICENSE b/LICENSE index 5c2dc74..e6a4843 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ The MIT License (MIT) -Copyright © 2021 Patrick Levin +Copyright © 2021,2024 Patrick Levin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/docs/example-explained.md b/docs/example-explained.md index 8ae5460..d0eb9d4 100644 --- a/docs/example-explained.md +++ b/docs/example-explained.md @@ -28,7 +28,7 @@ An initial attempt might look something like this: left_eye = detect_iris(image, left_eye_roi) # isolate the iris iris_location, iris_size = get_iris_position_and_size(left_eye, image) -iris = image.transform(iris_size, Image.EXTENT, data=iris_location) +iris = image.transform(iris_size, Transform.EXTENT, data=iris_location) # grayscale iris = iris.convert('L') # create mask diff --git a/fdlite/__init__.py b/fdlite/__init__.py index 039b6af..d0205ef 100644 --- a/fdlite/__init__.py +++ b/fdlite/__init__.py @@ -13,4 +13,4 @@ from .iris_landmark import iris_roi_from_face_landmarks # noqa:F401 -__version__ = '0.5.0' +__version__ = '0.6.0' diff --git a/fdlite/transform.py b/fdlite/transform.py index 784cbb5..fd53850 100644 --- a/fdlite/transform.py +++ b/fdlite/transform.py @@ -5,7 +5,7 @@ from typing import List, Optional, Sequence, Tuple, Union import numpy as np from PIL import Image -from PIL.Image import Image as PILImage +from PIL.Image import Image as PILImage, Resampling, Transform, Transpose from fdlite import ArgumentError, CoordinateRangeError, InvalidEnumError from fdlite.types import BBox, Detection, ImageTensor, Landmark, Rect """Functions for data transformations that are used by the detection models""" @@ -62,8 +62,8 @@ def image_to_tensor( src_points = roi.points() dst_points = [(0., 0.), (width, 0.), (width, height), (0., height)] coeffs = _perspective_transform_coeff(src_points, dst_points) - roi_image = img.transform(size=(width, height), method=Image.PERSPECTIVE, - data=coeffs, resample=Image.LINEAR) + roi_image = img.transform(size=(width, height), method=Transform.PERSPECTIVE, + data=coeffs, resample=Resampling.BILINEAR) # free some memory - we don't need the temporary image anymore if img != image: img.close() @@ -82,11 +82,11 @@ def image_to_tensor( if new_width != int(roi.width) or new_height != int(roi.height): pad_h, pad_v = int(pad_x * new_width), int(pad_y * new_height) roi_image = roi_image.transform( - size=(new_width, new_height), method=Image.EXTENT, + size=(new_width, new_height), method=Transform.EXTENT, data=(-pad_h, -pad_v, new_width - pad_h, new_height - pad_v)) - roi_image = roi_image.resize(output_size, resample=Image.BILINEAR) + roi_image = roi_image.resize(output_size, resample=Resampling.BILINEAR) if flip_horizontal: - roi_image = roi_image.transpose(method=Image.FLIP_LEFT_RIGHT) + roi_image = roi_image.transpose(method=Transpose.FLIP_LEFT_RIGHT) # finally, apply value range transform min_val, max_val = output_range tensor_data = np.asarray(roi_image, dtype=np.float32) diff --git a/setup.cfg b/setup.cfg index ee11a3a..d0af079 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- [metadata] name = face-detection-tflite -version = 0.5.1 +version = 0.6.0 author = Patrick Levin author_email = vertical-pink@protonmail.com description = A Python port of Google MediaPipe Face Detection modules @@ -26,11 +26,11 @@ classifiers = [options] packages = find: -python_requires = >= 3.7 +python_requires = >= 3.8 include_package_data = true install_requires = tensorflow>=2.3 - Pillow==9.5.0 + Pillow>=10.3.0 [flake8] exclude = diff --git a/setup.py b/setup.py index 0888acb..c219f82 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -Copyright © 2021 Patrick Levin +Copyright © 2021,2024 Patrick Levin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in