Skip to content

Commit

Permalink
Merge pull request #29 from markstur/fix_pillow
Browse files Browse the repository at this point in the history
Fix object detection bounding box drawing code to allow update of pillow
  • Loading branch information
bridgetmcg authored Jan 10, 2024
2 parents 9261035 + 83c3066 commit b252d6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions caikit_huggingface_demo/client/object_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,13 @@ 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))
label_draw.text((5, 2), key, font=FONT, fill="white")

image.paste(label_rectangle, (b.xmin, b.ymin))
image_draw.rectangle(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b252d6d

Please sign in to comment.