File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ dependencies = [
42
42
" pydantic-settings" ,
43
43
" requests" ,
44
44
" requests-mock" ,
45
+ " torchmetrics" ,
45
46
" torchvision" ,
46
47
" tzdata; sys_platform=='win32'" ,
47
48
" vws-auth-tools" ,
@@ -84,7 +85,6 @@ optional-dependencies.dev = [
84
85
" sphinxcontrib-spelling==8" ,
85
86
" sybil==6.1.1" ,
86
87
" tenacity==8.4.2" ,
87
- " torch==2.3.1" ,
88
88
" types-docker==7.1.0.20240626" ,
89
89
" types-pillow==10.2.0.20240520" ,
90
90
" types-pyyaml==6.0.12.20240311" ,
Original file line number Diff line number Diff line change 1
1
"""Matchers for query and duplicate requests."""
2
2
3
3
import io
4
- from typing import TYPE_CHECKING , Protocol , runtime_checkable
4
+ from typing import Protocol , runtime_checkable
5
5
6
- import piq # type: ignore[import-untyped]
7
6
from PIL import Image
7
+ from torchmetrics .image import (
8
+ StructuralSimilarityIndexMeasure ,
9
+ )
8
10
from torchvision .transforms import functional # type: ignore[import-untyped]
9
11
10
- if TYPE_CHECKING :
11
- import torch
12
-
13
12
14
13
@runtime_checkable
15
14
class ImageMatcher (Protocol ):
@@ -81,12 +80,10 @@ def __call__(
81
80
first_image_tensor_batch_dimension = first_image_tensor .unsqueeze (0 )
82
81
second_image_tensor_batch_dimension = second_image_tensor .unsqueeze (0 )
83
82
84
- # See https://github.com/photosynthesis-team/piq/pull/377
85
- # for fixing the type hint in ``piq``.
86
- ssim_value : torch .Tensor = piq .ssim ( # pyright: ignore[reportAssignmentType]
87
- x = first_image_tensor_batch_dimension ,
88
- y = second_image_tensor_batch_dimension ,
89
- data_range = 1.0 ,
83
+ ssim = StructuralSimilarityIndexMeasure (data_range = 1.0 )
84
+ ssim_value = ssim (
85
+ first_image_tensor_batch_dimension ,
86
+ second_image_tensor_batch_dimension ,
90
87
)
91
88
ssim_score = ssim_value .item ()
92
89
You can’t perform that action at this time.
0 commit comments