- if path_correct is None:
- path_correct = torch.zeros(imgs.size(0)) <= 1
- path_correct = path_correct.cpu().long().view(-1, 1, 1, 1)
- img = torch.tensor([224, 224, 224]).view(1, -1, 1, 1) * path_correct + torch.tensor(
- [255, 0, 0]
- ).view(1, -1, 1, 1) * (1 - path_correct)
+ if path_optimal is not None:
+ path_optimal = path_optimal.cpu().long().view(-1, 1, 1, 1)
+ img = (
+ img * (1 - path_optimal)
+ + torch.tensor([0, 255, 0]).view(1, -1, 1, 1) * path_optimal
+ )
+
+ if path_correct is not None:
+ path_correct = path_correct.cpu().long().view(-1, 1, 1, 1)
+ img = img * path_correct + torch.tensor([255, 0, 0]).view(1, -1, 1, 1) * (
+ 1 - path_correct
+ )
+