From 25746b3241369592a1804d53095fa87ea44e6b87 Mon Sep 17 00:00:00 2001 From: Jintao Lin Date: Mon, 13 Jul 2020 21:11:43 +0800 Subject: [PATCH] Add explanation for using denseflow to extract both rgb and flow (#17) --- docs/data_preparation.md | 8 +++++--- tools/data/build_rawframes.py | 8 ++++---- tools/data/kinetics400/preparing_kinetics400.md | 2 +- tools/data/mit/preparing_mit.md | 2 +- tools/data/mmit/preparing_mmit.md | 2 +- tools/data/sthv1/preparing_sthv1.md | 2 +- tools/data/sthv2/preparing_sthv2.md | 2 +- tools/data/thumos14/preparing_thumos14.md | 2 +- tools/data/ucf101/preparing_ucf101.md | 2 +- 9 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/data_preparation.md b/docs/data_preparation.md index 0c5f5e1ecd..72a5e200f4 100644 --- a/docs/data_preparation.md +++ b/docs/data_preparation.md @@ -41,14 +41,15 @@ Note that the videos should be arranged in either ### Extract frames -To extract frames and optical flow, [dense_flow](https://github.com/open-mmlab/denseflow) is needed. -You can use the following command to extract frames. +To extract both frames and optical flow, you can use the tool [denseflow](https://github.com/open-mmlab/denseflow) we wrote. +Since different frame extraction tools produce different number of frames, +it is beneficial to use the same tool to do both frame extraction and the flow computation, to avoid mismatching of frame counts. ```shell python build_rawframes.py ${SRC_FOLDER} ${OUT_FOLDER} [--task ${TASK}] [--level ${LEVEL}] \ [--num-worker ${NUM_WORKER}] [--flow-type ${FLOW_TYPE}] [--out-format ${OUT_FORMAT}] \ [--ext ${EXT}] [--new-width ${NEW_WIDTH}] [--new-height ${NEW_HEIGHT}] [--new-short ${NEW_SHORT}] - [--resume] + [--resume] [--use-opencv] ``` - `SRC_FOLDER`: Folder of the original video. @@ -63,6 +64,7 @@ python build_rawframes.py ${SRC_FOLDER} ${OUT_FOLDER} [--task ${TASK}] [--level - `NEW_HEIGHT`: Resized image height of output. - `NEW_SHORT`: Resized image short side length keeping ratio. - `--resume`: Whether to resume optical flow extraction instead of overwriting. +- `--use-opencv`: Whether to use OpenCV to extract rgb frames. The recommended practice is diff --git a/tools/data/build_rawframes.py b/tools/data/build_rawframes.py index b4666b0668..3887408f27 100644 --- a/tools/data/build_rawframes.py +++ b/tools/data/build_rawframes.py @@ -139,10 +139,6 @@ def parse_args(): default='avi', choices=['avi', 'mp4', 'webm'], help='video file extensions') - parser.add_argument( - '--use-opencv', - action='store_true', - help='Whether to use opencv to extract rgb frames') parser.add_argument( '--new-width', type=int, default=0, help='resize image width') parser.add_argument( @@ -158,6 +154,10 @@ def parse_args(): action='store_true', default=False, help='resume optical flow extraction instead of overwriting') + parser.add_argument( + '--use-opencv', + action='store_true', + help='Whether to use opencv to extract rgb frames') args = parser.parse_args() return args diff --git a/tools/data/kinetics400/preparing_kinetics400.md b/tools/data/kinetics400/preparing_kinetics400.md index 072c033a8a..b00d953d9f 100644 --- a/tools/data/kinetics400/preparing_kinetics400.md +++ b/tools/data/kinetics400/preparing_kinetics400.md @@ -39,7 +39,7 @@ bash rename_classnames.sh This part is **optional** if you only want to use the video loader. -Before extracting, please refer to [install.md](/docs/install.md) for installing [dense_flow](https://github.com/open-mmlab/denseflow). +Before extracting, please refer to [install.md](/docs/install.md) for installing [denseflow](https://github.com/open-mmlab/denseflow). If you have plenty of SSD space, then we recommend extracting frames there for better I/O performance. And you can run the following script to soft link the extracted frames. diff --git a/tools/data/mit/preparing_mit.md b/tools/data/mit/preparing_mit.md index 29766b6bda..972c653292 100644 --- a/tools/data/mit/preparing_mit.md +++ b/tools/data/mit/preparing_mit.md @@ -15,7 +15,7 @@ bash download_data.sh This part is **optional** if you only want to use the video loader. -Before extracting, please refer to [install.md](/docs/install.md) for installing [dense_flow](https://github.com/open-mmlab/denseflow). +Before extracting, please refer to [install.md](/docs/install.md) for installing [denseflow](https://github.com/open-mmlab/denseflow). If you have plenty of SSD space, then we recommend extracting frames there for better I/O performance. And you can run the following script to soft link the extracted frames. diff --git a/tools/data/mmit/preparing_mmit.md b/tools/data/mmit/preparing_mmit.md index dc03c87a88..1d85030702 100644 --- a/tools/data/mmit/preparing_mmit.md +++ b/tools/data/mmit/preparing_mmit.md @@ -15,7 +15,7 @@ bash download_data.sh This part is **optional** if you only want to use the video loader. -Before extracting, please refer to [install.md](/docs/install.md) for installing [dense_flow](https://github.com/open-mmlab/denseflow). +Before extracting, please refer to [install.md](/docs/install.md) for installing [denseflow](https://github.com/open-mmlab/denseflow). First, you can run the following script to soft link SSD. diff --git a/tools/data/sthv1/preparing_sthv1.md b/tools/data/sthv1/preparing_sthv1.md index 9e2981dd76..d9f2684f18 100644 --- a/tools/data/sthv1/preparing_sthv1.md +++ b/tools/data/sthv1/preparing_sthv1.md @@ -21,7 +21,7 @@ cd $MMACTION2/tools/data/sthv1/ This part is **optional** if you only want to use the video loader. -Before extracting, please refer to [install.md](/docs/install.md) for installing [dense_flow](https://github.com/open-mmlab/denseflow). +Before extracting, please refer to [install.md](/docs/install.md) for installing [denseflow](https://github.com/open-mmlab/denseflow). If you have plenty of SSD space, then we recommend extracting frames there for better I/O performance. diff --git a/tools/data/sthv2/preparing_sthv2.md b/tools/data/sthv2/preparing_sthv2.md index 440b627ccd..0845bc9b65 100644 --- a/tools/data/sthv2/preparing_sthv2.md +++ b/tools/data/sthv2/preparing_sthv2.md @@ -20,7 +20,7 @@ cat 20bn-something-something-v2-?? | tar zx This part is **optional** if you only want to use the video loader. -Before extracting, please refer to [install.md](/docs/install.md) for installing [dense_flow](https://github.com/open-mmlab/denseflow). +Before extracting, please refer to [install.md](/docs/install.md) for installing [denseflow](https://github.com/open-mmlab/denseflow). If you have plenty of SSD space, then we recommend extracting frames there for better I/O performance. diff --git a/tools/data/thumos14/preparing_thumos14.md b/tools/data/thumos14/preparing_thumos14.md index 513be4b63d..8a342a3752 100644 --- a/tools/data/thumos14/preparing_thumos14.md +++ b/tools/data/thumos14/preparing_thumos14.md @@ -25,7 +25,7 @@ bash download_videos.sh This part is **optional** if you only want to use the video loader. -Before extracting, please refer to [install.md](/docs/install.md) for installing [dense_flow](https://github.com/open-mmlab/denseflow). +Before extracting, please refer to [install.md](/docs/install.md) for installing [denseflow](https://github.com/open-mmlab/denseflow). If you have plenty of SSD space, then we recommend extracting frames there for better I/O performance. diff --git a/tools/data/ucf101/preparing_ucf101.md b/tools/data/ucf101/preparing_ucf101.md index 061f2a876b..8f4012619e 100644 --- a/tools/data/ucf101/preparing_ucf101.md +++ b/tools/data/ucf101/preparing_ucf101.md @@ -23,7 +23,7 @@ bash download_videos.sh This part is **optional** if you only want to use the video loader. -Before extracting, please refer to [install.md](/docs/install.md) for installing [dense_flow](https://github.com/open-mmlab/denseflow). +Before extracting, please refer to [install.md](/docs/install.md) for installing [denseflow](https://github.com/open-mmlab/denseflow). If you have plenty of SSD space, then we recommend extracting frames there for better I/O performance. The extracted frames (RGB + Flow) will take up about 100GB.