(self, model_output, target, w)
| 62 | return self.get_loss(model_output, input, w) |
| 63 | |
| 64 | def get_loss(self, model_output, target, w): |
| 65 | if self.type == "l2": |
| 66 | return torch.mean((w * (model_output - target) ** 2).reshape(target.shape[0], -1), 1) |
| 67 | elif self.type == "l1": |
| 68 | return torch.mean((w * (model_output - target).abs()).reshape(target.shape[0], -1), 1) |
| 69 | elif self.type == "lpips": |
| 70 | loss = self.lpips(model_output, target).reshape(-1) |
| 71 | return loss |
| 72 | |
| 73 | |
| 74 | class VideoDiffusionLoss(StandardDiffusionLoss): |