@@ -42,14 +42,14 @@ def read_file(path: str) -> torch.Tensor:
42
42
with one dimension.
43
43
44
44
Args:
45
- path (str): the path to the file to be read
45
+ path (str or ``pathlib.Path`` ): the path to the file to be read
46
46
47
47
Returns:
48
48
data (Tensor)
49
49
"""
50
50
if not torch .jit .is_scripting () and not torch .jit .is_tracing ():
51
51
_log_api_usage_once (read_file )
52
- data = torch .ops .image .read_file (path )
52
+ data = torch .ops .image .read_file (str ( path ) )
53
53
return data
54
54
55
55
@@ -59,12 +59,12 @@ def write_file(filename: str, data: torch.Tensor) -> None:
59
59
file.
60
60
61
61
Args:
62
- filename (str): the path to the file to be written
62
+ filename (str or ``pathlib.Path`` ): the path to the file to be written
63
63
data (Tensor): the contents to be written to the output file
64
64
"""
65
65
if not torch .jit .is_scripting () and not torch .jit .is_tracing ():
66
66
_log_api_usage_once (write_file )
67
- torch .ops .image .write_file (filename , data )
67
+ torch .ops .image .write_file (str ( filename ) , data )
68
68
69
69
70
70
def decode_png (
@@ -123,7 +123,7 @@ def write_png(input: torch.Tensor, filename: str, compression_level: int = 6):
123
123
Args:
124
124
input (Tensor[channels, image_height, image_width]): int8 image tensor of
125
125
``c`` channels, where ``c`` must be 1 or 3.
126
- filename (str): Path to save the image.
126
+ filename (str or ``pathlib.Path`` ): Path to save the image.
127
127
compression_level (int): Compression factor for the resulting file, it must be a number
128
128
between 0 and 9. Default: 6
129
129
"""
@@ -211,7 +211,7 @@ def write_jpeg(input: torch.Tensor, filename: str, quality: int = 75):
211
211
Args:
212
212
input (Tensor[channels, image_height, image_width]): int8 image tensor of ``c``
213
213
channels, where ``c`` must be 1 or 3.
214
- filename (str): Path to save the image.
214
+ filename (str or ``pathlib.Path`` ): Path to save the image.
215
215
quality (int): Quality of the resulting JPEG file, it must be a number
216
216
between 1 and 100. Default: 75
217
217
"""
@@ -259,7 +259,7 @@ def read_image(
259
259
The values of the output tensor are uint8 in [0, 255].
260
260
261
261
Args:
262
- path (str): path of the JPEG or PNG image.
262
+ path (str or ``pathlib.Path`` ): path of the JPEG or PNG image.
263
263
mode (ImageReadMode): the read mode used for optionally converting the image.
264
264
Default: ``ImageReadMode.UNCHANGED``.
265
265
See ``ImageReadMode`` class for more information on various
0 commit comments