.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "build/examples_action_recognition/decord_loader.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_build_examples_action_recognition_decord_loader.py: 10. Introducing Decord: an efficient video reader ==================================================== Training deep neural networks on videos is very time consuming. For example, training a state-of-the-art SlowFast network on Kinetics400 dataset using a server with 8 V100 GPUs takes more than 10 days. Slow training causes long research cycles and is not friendly for new comers and students to work on video related problems. There are several reasons causing the slowness, big batch of data, inefficiency of video reader and huge model computation. Another troubling matter is the complex data preprocessing and huge storage cost. Take Kinetics400 dataset as an example, this dataset has about 240K training and 20K validation videos. All the videos take 450G disk space. However, if we decode the videos to frames and use image loader to train the model, the decoded frames will take 6.8T disk space, which is unacceptable to most people. In addition, the decoding process is slow. It takes 1.5 days using 60 workers to decode all the videos to frames. If we use 8 workers (as in common laptop or standard workstation), it will take a week to perform such data preprocessing even before your actual training. Given the challenges aforementioned, in this tutotial, we introduce a new video reader, `Decord `_. Decord is efficient and flexible. It provides convenient video slicing methods based on a wrapper on top of hardware accelerated video decoders, e.g. FFMPEG/LibAV and Nvidia Codecs. It is designed to handle awkward video shuffling experience in order to provide smooth experiences similar to random image loader for deep learning. In addition, it works cross-platform, e.g., Linux, Windows and Mac OS. With the new video reader, you don't need to decode videos to frames anymore, just start training on your video dataset with even higher training speed. .. GENERATED FROM PYTHON SOURCE LINES 25-32 Install ------- Decord is easy to install, just :: pip install decord .. GENERATED FROM PYTHON SOURCE LINES 34-38 Usage ----- We provide some usage cases here to get you started. For complete API, please refer to official documentation. .. GENERATED FROM PYTHON SOURCE LINES 40-41 Suppose we want to read a video. Let's download the example video first. .. GENERATED FROM PYTHON SOURCE LINES 41-48 .. code-block:: default from gluoncv import utils url = 'https://github.com/bryanyzhu/tiny-ucf101/raw/master/abseiling_k400.mp4' video_fname = utils.download(url) from decord import VideoReader vr = VideoReader(video_fname) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Downloading abseiling_k400.mp4 from https://github.com/bryanyzhu/tiny-ucf101/raw/master/abseiling_k400.mp4... 0%| | 0/782 [00:00`_ and demonstrate 2x speed up as well. In conclusion, Decord is an efficient and flexible video reader. It supports get_batch, GPU loading, fast random access, etc, which is perfectly designed for training video deep neural networks. We use Decord in our video model training for large-scale datasets and observe similar speed as using image loaders on decoded video frames. This significanly reduces the data preprocessing time and the storage cost for large-scale video datasets. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 39.780 seconds) .. _sphx_glr_download_build_examples_action_recognition_decord_loader.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: decord_loader.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: decord_loader.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_