Convert a numpy image to a pytorch tensor
(images)
| 70 | |
| 71 | @staticmethod |
| 72 | def numpy_to_pt(images): |
| 73 | """ |
| 74 | Convert a numpy image to a pytorch tensor |
| 75 | """ |
| 76 | if images.ndim == 3: |
| 77 | images = images[..., None] |
| 78 | |
| 79 | images = torch.from_numpy(images.transpose(0, 3, 1, 2)) |
| 80 | return images |
| 81 | |
| 82 | @staticmethod |
| 83 | def pt_to_numpy(images): |