Skip to content

Commit

Permalink
update dependency to Pillow 10.3.0, fixes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
patlevin committed May 13, 2024
1 parent f68948c commit 17e567d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/example-explained.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fdlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
from .iris_landmark import iris_roi_from_face_landmarks # noqa:F401


__version__ = '0.5.0'
__version__ = '0.6.0'
12 changes: 6 additions & 6 deletions fdlite/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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 = [email protected]
description = A Python port of Google MediaPipe Face Detection modules
Expand All @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 17e567d

Please sign in to comment.