File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 7
7
from torchmetrics .image import (
8
8
StructuralSimilarityIndexMeasure ,
9
9
)
10
- from torchvision . transforms import functional # type: ignore[import-untyped]
10
+ from torchvision import transforms # type: ignore[import-untyped]
11
11
12
12
13
13
@runtime_checkable
@@ -74,8 +74,10 @@ def __call__(
74
74
first_image = first_image .resize (size = target_size )
75
75
second_image = second_image .resize (size = target_size )
76
76
77
- first_image_tensor = functional .to_tensor (pic = first_image ) # pyright: ignore[reportUnknownMemberType]
78
- second_image_tensor = functional .to_tensor (pic = second_image ) # pyright: ignore[reportUnknownMemberType]
77
+ transform = transforms .ToTensor ()
78
+
79
+ first_image_tensor = transform (pic = first_image )
80
+ second_image_tensor = transform (pic = second_image )
79
81
80
82
first_image_tensor_batch_dimension = first_image_tensor .unsqueeze (0 )
81
83
second_image_tensor_batch_dimension = second_image_tensor .unsqueeze (0 )
Original file line number Diff line number Diff line change 8
8
9
9
import piq # type: ignore[import-untyped]
10
10
from PIL import Image
11
- from torchvision . transforms import functional # type: ignore[import-untyped]
11
+ from torchvision import transforms # type: ignore[import-untyped]
12
12
13
13
14
14
@functools .cache
@@ -25,7 +25,8 @@ def _get_brisque_target_tracking_rating(image_content: bytes) -> int:
25
25
"""
26
26
image_file = io .BytesIO (initial_bytes = image_content )
27
27
image = Image .open (fp = image_file )
28
- image_tensor = functional .to_tensor (pic = image ) * 255 # pyright: ignore[reportUnknownMemberType]
28
+ transform = transforms .ToTensor ()
29
+ image_tensor = transform (pic = image )
29
30
image_tensor = image_tensor .unsqueeze (0 )
30
31
try :
31
32
brisque_score = piq .brisque (x = image_tensor , data_range = 255 )
You can’t perform that action at this time.
0 commit comments