Skip to content

Commit 551c479

Browse files
committed
WIP
1 parent 005f094 commit 551c479

File tree

1 file changed

+35
-47
lines changed

1 file changed

+35
-47
lines changed

docs/source/io.rst

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,24 @@ Decoding / Encoding images and videos
33

44
.. currentmodule:: torchvision.io
55

6-
The :mod:`torchvision.io` package provides functions for performing IO
7-
operations. They are currently specific to reading and writing images and
8-
videos.
6+
The :mod:`torchvision.io` module provides utilities for decoding and encoding
7+
images and videos.
98

10-
Images
11-
------
9+
Image Decoding
10+
--------------
1211

1312
Torchvision currently supports decoding JPEG, PNG, WEBP and GIF images. JPEG
1413
decoding can also be done on CUDA GPUs.
1514

16-
For encoding, JPEG (cpu and CUDA) and PNG are supported.
17-
1815
.. autosummary::
1916
:toctree: generated/
2017
:template: function.rst
2118

2219
decode_image
23-
encode_jpeg
2420
decode_jpeg
25-
write_jpeg
21+
encode_png
2622
decode_gif
2723
decode_webp
28-
encode_png
29-
decode_png
30-
write_png
31-
read_file
32-
write_file
3324

3425
.. autosummary::
3526
:toctree: generated/
@@ -41,14 +32,42 @@ Obsolete decoding function:
4132

4233
.. autosummary::
4334
:toctree: generated/
44-
:template: class.rst
35+
:template: function.rst
4536

4637
read_image
4738

39+
Image Encoding
40+
--------------
41+
42+
For encoding, JPEG (cpu and CUDA) and PNG are supported.
43+
44+
45+
.. autosummary::
46+
:toctree: generated/
47+
:template: function.rst
48+
49+
encode_jpeg
50+
write_jpeg
51+
encode_png
52+
write_png
53+
54+
IO operations
55+
-------------
56+
57+
.. autosummary::
58+
:toctree: generated/
59+
:template: function.rst
60+
61+
read_file
62+
write_file
4863

4964
Video
5065
-----
5166

67+
.. warning::
68+
69+
TODO recommend torchcodec
70+
5271
.. autosummary::
5372
:toctree: generated/
5473
:template: function.rst
@@ -58,45 +77,14 @@ Video
5877
write_video
5978

6079

61-
Fine-grained video API
62-
^^^^^^^^^^^^^^^^^^^^^^
80+
**Fine-grained video API**
6381

6482
In addition to the :mod:`read_video` function, we provide a high-performance
6583
lower-level API for more fine-grained control compared to the :mod:`read_video` function.
6684
It does all this whilst fully supporting torchscript.
6785

68-
.. betastatus:: fine-grained video API
69-
7086
.. autosummary::
7187
:toctree: generated/
7288
:template: class.rst
7389

7490
VideoReader
75-
76-
77-
Example of inspecting a video:
78-
79-
.. code:: python
80-
81-
import torchvision
82-
video_path = "path to a test video"
83-
# Constructor allocates memory and a threaded decoder
84-
# instance per video. At the moment it takes two arguments:
85-
# path to the video file, and a wanted stream.
86-
reader = torchvision.io.VideoReader(video_path, "video")
87-
88-
# The information about the video can be retrieved using the
89-
# `get_metadata()` method. It returns a dictionary for every stream, with
90-
# duration and other relevant metadata (often frame rate)
91-
reader_md = reader.get_metadata()
92-
93-
# metadata is structured as a dict of dicts with following structure
94-
# {"stream_type": {"attribute": [attribute per stream]}}
95-
#
96-
# following would print out the list of frame rates for every present video stream
97-
print(reader_md["video"]["fps"])
98-
99-
# we explicitly select the stream we would like to operate on. In
100-
# the constructor we select a default video stream, but
101-
# in practice, we can set whichever stream we would like
102-
video.set_current_stream("video:0")

0 commit comments

Comments
 (0)