Unverified Commit 552a4060 authored by Sugato Ray's avatar Sugato Ray Committed by GitHub
Browse files

bug-fix to issue #4042 (#4043)

* allow single-channel-images in draw_bounding_boxes

This is bug-fix for issue #4042.

https://github.com/pytorch/vision/issues/4042

* change made for passing linting requirements

#4042
parent 093757db
...@@ -180,6 +180,10 @@ def draw_bounding_boxes( ...@@ -180,6 +180,10 @@ def draw_bounding_boxes(
raise ValueError("Pass individual images, not batches") raise ValueError("Pass individual images, not batches")
ndarr = image.permute(1, 2, 0).numpy() ndarr = image.permute(1, 2, 0).numpy()
# allow single-channel-images
# shape: (1, H, W) with C = 1
if ndarr.shape[-1] == 1:
ndarr = np.tile(ndarr, (1, 1, 3))
img_to_draw = Image.fromarray(ndarr) img_to_draw = Image.fromarray(ndarr)
img_boxes = boxes.to(torch.int64).tolist() img_boxes = boxes.to(torch.int64).tolist()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment