Skip to content

Commit e07c90d

Browse files
authored
Merge pull request #12 from luyuxuan98/main
fix(ssim): correct SSIMLoss input scaling by multiplying with 255
2 parents 88683e2 + 112b75a commit e07c90d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

basicgs/losses/basic_loss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def forward(self, pred, target, weight=None, **kwargs):
147147
weight (Tensor, optional): of shape (N, C, H, W). Element-wise weights. Default: None.
148148
"""
149149
pred = pred.clip(None, 1)
150-
l = (1 - _ssim_map_pth(pred, target))
150+
l = (1 - _ssim_map_pth(pred * 255., target * 255.))
151151
l = weight_reduce_loss(l, weight, reduction=self.reduction)
152152
return self.loss_weight * l
153153

@@ -193,4 +193,4 @@ def forward(self, pred, target, weight=None, **kwargs):
193193
loss = l1_loss(rendered_linear_rgb, target, weight=None, reduction='none')
194194
scaling_grad = self.get_scaling_grad(rendered_linear_rgb)
195195
l = loss * scaling_grad
196-
return weight_reduce_loss(l, weight, self.reduction)
196+
return weight_reduce_loss(l, weight, self.reduction)

0 commit comments

Comments
 (0)