test updates, revert Results to CPU

This commit is contained in:
Glenn Jocher
2023-02-24 03:22:33 -08:00
parent 3ea659411b
commit bfc078b32f
3 changed files with 9 additions and 7 deletions

View File

@ -114,7 +114,9 @@ class Annotator:
self.im = np.asarray(self.im).copy()
if len(masks) == 0:
self.im[:] = im_gpu.permute(1, 2, 0).contiguous().cpu().numpy() * 255
colors = torch.tensor(colors, device=im_gpu.device, dtype=torch.float32) / 255.0
if im_gpu.device != masks.device:
im_gpu = im_gpu.to(masks.device)
colors = torch.tensor(colors, device=masks.device, dtype=torch.float32) / 255.0
colors = colors[:, None, None] # shape(n,1,1,3)
masks = masks.unsqueeze(3) # shape(n,h,w,1)
masks_color = masks * (colors * alpha) # shape(n,h,w,3)