50
50
51
51
52
52
class ImageReadMode (Enum ):
53
+ """
54
+ Support for various modes while reading images.
55
+
56
+ Use `ImageReadMode.UNCHANGED` for loading the image as-is,
57
+ `ImageReadMode.GRAY` for converting to grayscale,
58
+ `ImageReadMode.GRAY_ALPHA` for grayscale with transparency,
59
+ `ImageReadMode.RGB` for RGB and `ImageReadMode.RGB_ALPHA` for
60
+ RGB with transparency.
61
+ """
53
62
UNCHANGED = 0
54
63
GRAY = 1
55
64
GRAY_ALPHA = 2
@@ -62,7 +71,7 @@ def read_file(path: str) -> torch.Tensor:
62
71
Reads and outputs the bytes contents of a file as a uint8 Tensor
63
72
with one dimension.
64
73
65
- Arguments :
74
+ Args :
66
75
path (str): the path to the file to be read
67
76
68
77
Returns:
@@ -77,7 +86,7 @@ def write_file(filename: str, data: torch.Tensor) -> None:
77
86
Writes the contents of a uint8 tensor with one dimension to a
78
87
file.
79
88
80
- Arguments :
89
+ Args :
81
90
filename (str): the path to the file to be written
82
91
data (Tensor): the contents to be written to the output file
83
92
"""
@@ -90,15 +99,13 @@ def decode_png(input: torch.Tensor, mode: ImageReadMode = ImageReadMode.UNCHANGE
90
99
Optionally converts the image to the desired format.
91
100
The values of the output tensor are uint8 between 0 and 255.
92
101
93
- Arguments :
102
+ Args :
94
103
input (Tensor[1]): a one dimensional uint8 tensor containing
95
104
the raw bytes of the PNG image.
96
105
mode (ImageReadMode): the read mode used for optionally
97
- converting the image. Use `ImageReadMode.UNCHANGED` for loading
98
- the image as-is, `ImageReadMode.GRAY` for converting to grayscale,
99
- `ImageReadMode.GRAY_ALPHA` for grayscale with transparency,
100
- `ImageReadMode.RGB` for RGB and `ImageReadMode.RGB_ALPHA` for
101
- RGB with transparency. Default: `ImageReadMode.UNCHANGED`
106
+ converting the image. Default: `ImageReadMode.UNCHANGED`.
107
+ See `ImageReadMode` class for more information on various
108
+ available modes.
102
109
103
110
Returns:
104
111
output (Tensor[image_channels, image_height, image_width])
@@ -155,13 +162,13 @@ def decode_jpeg(input: torch.Tensor, mode: ImageReadMode = ImageReadMode.UNCHANG
155
162
Optionally converts the image to the desired format.
156
163
The values of the output tensor are uint8 between 0 and 255.
157
164
158
- Arguments :
165
+ Args :
159
166
input (Tensor[1]): a one dimensional uint8 tensor containing
160
167
the raw bytes of the JPEG image.
161
168
mode (ImageReadMode): the read mode used for optionally
162
- converting the image. Use `ImageReadMode.UNCHANGED` for loading
163
- the image as-is, `ImageReadMode.GRAY` for converting to grayscale
164
- and `ImageReadMode.RGB` for RGB. Default: `ImageReadMode.UNCHANGED`
169
+ converting the image. Default: `ImageReadMode.UNCHANGED`.
170
+ See `ImageReadMode` class for more information on various
171
+ available modes.
165
172
166
173
Returns:
167
174
output (Tensor[image_channels, image_height, image_width])
@@ -229,11 +236,10 @@ def decode_image(input: torch.Tensor, mode: ImageReadMode = ImageReadMode.UNCHAN
229
236
a one dimensional uint8 tensor containing the raw bytes of the
230
237
PNG or JPEG image.
231
238
mode: ImageReadMode
232
- the read mode used for optionally converting the image. JPEG
233
- and PNG images have different permitted values. The default
234
- value is `ImageReadMode.UNCHANGED` and it keeps the image as-is.
235
- See `decode_jpeg()` and `decode_png()` for more information.
236
- Default: `ImageReadMode.UNCHANGED`
239
+ the read mode used for optionally converting the image.
240
+ Default: `ImageReadMode.UNCHANGED`.
241
+ See `ImageReadMode` class for more information on various
242
+ available modes.
237
243
238
244
Returns
239
245
-------
@@ -254,11 +260,10 @@ def read_image(path: str, mode: ImageReadMode = ImageReadMode.UNCHANGED) -> torc
254
260
path: str
255
261
path of the JPEG or PNG image.
256
262
mode: ImageReadMode
257
- the read mode used for optionally converting the image. JPEG
258
- and PNG images have different permitted values. The default
259
- value is `ImageReadMode.UNCHANGED` and it keeps the image as-is.
260
- See `decode_jpeg()` and `decode_png()` for more information.
261
- Default: `ImageReadMode.UNCHANGED`
263
+ the read mode used for optionally converting the image.
264
+ Default: `ImageReadMode.UNCHANGED`.
265
+ See `ImageReadMode` class for more information on various
266
+ available modes.
262
267
263
268
Returns
264
269
-------
0 commit comments