Save tensor as image.
(tensor, step)
| 73 | return attr_gabor |
| 74 | |
| 75 | def save(tensor, step): |
| 76 | """Save tensor as image.""" |
| 77 | mean = [0.485, 0.456, 0.406] |
| 78 | std = [0.229, 0.224, 0.225] |
| 79 | mean_out = -1 * torch.tensor(mean) / torch.tensor(std) |
| 80 | std_out = 1 / torch.tensor(std) |
| 81 | output = normalize(tensor, mean_out, std_out, inplace=False) |
| 82 | output = tensor2img(output) |
| 83 | imwrite(output, f"result/cond/test/{step}.png") |
| 84 | |
| 85 | class Hook_back_loop: |
| 86 | """钩子类,用于捕获前向和后向信息""" |
nothing calls this directly
no test coverage detected