Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes draw methods for grayscale images #807

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions icevision/visualize/draw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def draw_bbox(
# Calculate image dimensions
dims = sorted(img.shape, reverse=True)
color = as_rgb_tuple(color)
img = PIL.Image.fromarray(img)
img = PIL.Image.fromarray(img.squeeze()).convert("RGB")
draw = PIL.ImageDraw.Draw(img)

# corner thickness is linearly correlated with the smaller image dimension.
Expand Down Expand Up @@ -482,7 +482,7 @@ def draw_mask(
raise ValueError(
f"`border_thickness` must be an odd number. You entered {border_thickness}"
)
img = PIL.Image.fromarray(img)
img = PIL.Image.fromarray(img.squeeze())
w, h = img.size

mask_idxs = np.where(mask.data)
Expand Down Expand Up @@ -520,7 +520,7 @@ def draw_keypoints(
# calculate scaling for points and connections
img_h, img_w, _ = img.shape
img_area = img_h * img_w
img = PIL.Image.fromarray(img)
img = PIL.Image.fromarray(img.squeeze())
draw = PIL.ImageDraw.Draw(img)
dynamic_size = int(0.01867599 * (img_area ** 0.4422045))
dynamic_size = max(dynamic_size, 1)
Expand Down