Convert a Tensor to numpy image.
(inp)
| 211 | |
| 212 | |
| 213 | def convert_image_np(inp): |
| 214 | """Convert a Tensor to numpy image.""" |
| 215 | inp = inp.numpy().transpose((1, 2, 0)) |
| 216 | mean = np.array([0.485, 0.456, 0.406]) |
| 217 | std = np.array([0.229, 0.224, 0.225]) |
| 218 | inp = std * inp + mean |
| 219 | inp = np.clip(inp, 0, 1) |
| 220 | return inp |
| 221 | |
| 222 | # We want to visualize the output of the spatial transformers layer |
| 223 | # after the training, we visualize a batch of input images and |