MCPcopy Create free account
hub / github.com/OpenDriveLab/OccNet / save_tensor

Function save_tensor

projects/mmdet3d_plugin/models/utils/visual.py:15–24  ·  view source on GitHub ↗
(tensor, path, pad_value=254.0,)

Source from the content-addressed store, hash-verified

13
14
15def save_tensor(tensor, path, pad_value=254.0,):
16 print('save_tensor', path)
17 tensor = tensor.to(torch.float).detach().cpu()
18 if tensor.type() == 'torch.BoolTensor':
19 tensor = tensor*255
20 if len(tensor.shape) == 3:
21 tensor = tensor.unsqueeze(1)
22 tensor = make_grid(tensor, pad_value=pad_value, normalize=False).permute(1, 2, 0).numpy().copy()
23 torchvision.utils.save_image(torch.tensor(tensor).permute(2, 0, 1), path)
24 convert_color(path)

Callers

nothing calls this directly

Calls 1

convert_colorFunction · 0.85

Tested by

no test coverage detected