(img)
| 72 | |
| 73 | # convert uint to 4-dimensional torch tensor |
| 74 | def uint2tensor4(img): |
| 75 | if img.ndim == 2: |
| 76 | img = np.expand_dims(img, axis=2) |
| 77 | return torch.from_numpy(np.ascontiguousarray(img)).permute(2, 0, 1).float().div(255.).unsqueeze(0) |
| 78 | |
| 79 | # convert 2/3/4-dimensional torch tensor to uint |
| 80 | def tensor2uint(img): |