Skip to content

Commit 32b7175

Browse files
committed
Enhance MultiScaleSSIM: Add data_range property and update test fixtures for larger image sizes #17
1 parent 43ffd32 commit 32b7175

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

kaira/metrics/image/ssim.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ def compute_with_stats(self, x: torch.Tensor, y: torch.Tensor, *args: Any, **kwa
227227
return values.mean(), torch.tensor(0.0)
228228
return values.mean(), values.std()
229229

230+
@property
231+
def data_range(self) -> float:
232+
"""Get the data range used by the underlying torchmetrics implementation."""
233+
return self.ms_ssim.data_range
234+
230235

231236
# Alias for backward compatibility
232237
SSIM = StructuralSimilarityIndexMeasure

tests/losses/test_losses_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
@pytest.fixture
2727
def sample_images():
2828
"""Fixture for creating sample image tensor."""
29-
return torch.rand(2, 3, 32, 32)
29+
return torch.rand(2, 3, 192, 192) # Larger size for MS-SSIM compatibility
3030

3131

3232
@pytest.fixture
3333
def sample_target_images():
3434
"""Fixture for creating sample target image tensor."""
35-
return torch.rand(2, 3, 32, 32)
35+
return torch.rand(2, 3, 192, 192) # Larger size for MS-SSIM compatibility
3636

3737

3838
def test_mse_loss(sample_images, sample_target_images):

0 commit comments

Comments
 (0)