From e961e9ff579c0f8af063986e39a7d2e5107c7c8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 01:36:52 +0000 Subject: [PATCH 1/3] Bump pillow from 9.5.0 to 10.0.1 Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.5.0 to 10.0.1. - [Release notes](https://github.com/python-pillow/Pillow/releases) - [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst) - [Commits](https://github.com/python-pillow/Pillow/compare/9.5.0...10.0.1) --- updated-dependencies: - dependency-name: pillow dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ca86aae..995a511 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ caikit[all]==0.10.1 requests==2.31.0 -Pillow==9.5.0 +Pillow==10.0.1 click==8.1.3 timm==0.9.1 # backend only From 8e56f139eb03e1665c506a7395f48d57c85b1084 Mon Sep 17 00:00:00 2001 From: markstur Date: Wed, 10 Jan 2024 12:51:13 -0800 Subject: [PATCH 2/3] Use FONT.getbbox instead of FONT.getsize to update pillow Object detection bounding box drawing code updated to work with updated pillow API. Signed-off-by: markstur --- caikit_huggingface_demo/client/object_detection.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/caikit_huggingface_demo/client/object_detection.py b/caikit_huggingface_demo/client/object_detection.py index 7ee533f..2040e0d 100644 --- a/caikit_huggingface_demo/client/object_detection.py +++ b/caikit_huggingface_demo/client/object_detection.py @@ -66,16 +66,15 @@ def fn(self, model, image_array): label if counter[label] == 1 else f"{label}-{counter[label]}" ) # Append counter when repeated b = result.box - text_size = FONT.getsize(key) - label_size = (text_size[0] + 10, text_size[1] + 10) + _, _, width, height = FONT.getbbox(key) + label_size = (width + 10, height + 10) label_rectangle = Image.new( "RGBA", label_size, ImageColor.getrgb(color) + (0,) ) # with transparency label_draw = ImageDraw.Draw(label_rectangle) - # label_draw.rectangle((5, 2)+label_size, fill=ImageColor.getrgb(color)+(127,)) # (255, 255, 0, 100)) label_draw.text( (5, 2), key, font=FONT, fill="white" - ) # fill=(255, 255, 0, 255)) + ) image.paste(label_rectangle, (b.xmin, b.ymin)) image_draw.rectangle( From 83c30667638906c404800c3960d34946026f25a2 Mon Sep 17 00:00:00 2001 From: markstur Date: Wed, 10 Jan 2024 13:23:36 -0800 Subject: [PATCH 3/3] Fix formatting Signed-off-by: markstur --- caikit_huggingface_demo/client/object_detection.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/caikit_huggingface_demo/client/object_detection.py b/caikit_huggingface_demo/client/object_detection.py index 2040e0d..cb1d961 100644 --- a/caikit_huggingface_demo/client/object_detection.py +++ b/caikit_huggingface_demo/client/object_detection.py @@ -72,9 +72,7 @@ def fn(self, model, image_array): "RGBA", label_size, ImageColor.getrgb(color) + (0,) ) # with transparency label_draw = ImageDraw.Draw(label_rectangle) - label_draw.text( - (5, 2), key, font=FONT, fill="white" - ) + label_draw.text((5, 2), key, font=FONT, fill="white") image.paste(label_rectangle, (b.xmin, b.ymin)) image_draw.rectangle(