File size: 7,620 Bytes
d3dbf03 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | # Preparing ActivityNet
## Introduction
<!-- [DATASET] -->
```BibTeX
@article{Heilbron2015ActivityNetAL,
title={ActivityNet: A large-scale video benchmark for human activity understanding},
author={Fabian Caba Heilbron and Victor Escorcia and Bernard Ghanem and Juan Carlos Niebles},
journal={2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2015},
pages={961-970}
}
```
For basic dataset information, please refer to the official [website](http://activity-net.org/).
For action detection, you can either use the ActivityNet rescaled feature provided in this [repo](https://github.com/wzmsltw/BSN-boundary-sensitive-network#code-and-data-preparation) or extract feature with mmaction2 (which has better performance).
We release both pipeline.
Before we start, please make sure that current working directory is `$MMACTION2/tools/data/activitynet/`.
## Option 1: Use the ActivityNet rescaled feature provided in this [repo](https://github.com/wzmsltw/BSN-boundary-sensitive-network#code-and-data-preparation)
### Step 1. Download Annotations
First of all, you can run the following script to download annotation files.
```shell
bash download_feature_annotations.sh
```
### Step 2. Prepare Videos Features
Then, you can run the following script to download activitynet features.
```shell
bash download_features.sh
```
### Step 3. Process Annotation Files
Next, you can run the following script to process the downloaded annotation files for training and testing.
It first merges the two annotation files together and then separates the annoations by `train`, `val` and `test`.
```shell
python process_annotations.py
```
## Option 2: Extract ActivityNet feature using MMAction2 with all videos provided in official [website](http://activity-net.org/)
### Step 1. Download Annotations
First of all, you can run the following script to download annotation files.
```shell
bash download_annotations.sh
```
### Step 2. Prepare Videos
Then, you can run the following script to prepare videos.
The codes are adapted from the [official crawler](https://github.com/activitynet/ActivityNet/tree/master/Crawler/Kinetics). Note that this might take a long time.
```shell
bash download_videos.sh
```
Since some videos in the ActivityNet dataset might be no longer available on YouTube, official [website](http://activity-net.org/) has made the full dataset available on Google and Baidu drives.
To accommodate missing data requests, you can fill in this [request form](https://docs.google.com/forms/d/e/1FAIpQLSeKaFq9ZfcmZ7W0B0PbEhfbTHY41GeEgwsa7WobJgGUhn4DTQ/viewform) provided in official [download page](http://activity-net.org/download.html) to have a 7-day-access to download the videos from the drive folders.
We also provide download steps for annotations from [BSN repo](https://github.com/wzmsltw/BSN-boundary-sensitive-network#code-and-data-preparation)
```shell
bash download_bsn_videos.sh
```
For this case, the downloading scripts update the annotation file after downloading to make sure every video in it exists.
### Step 3. Extract RGB and Flow
Before extracting, please refer to [install.md](/docs/en/get_started/installation.md) for installing [denseflow](https://github.com/open-mmlab/denseflow).
Use following scripts to extract both RGB and Flow.
```shell
bash extract_frames.sh
```
The command above can generate images with new short edge 256. If you want to generate images with short edge 320 (320p), or with fix size 340x256, you can change the args `--new-short 256` to `--new-short 320` or `--new-width 340 --new-height 256`.
More details can be found in [prepare dataset](/docs/en/user_guides/prepare_dataset.md)
### Step 4. Generate File List for ActivityNet Finetuning
With extracted frames, you can generate video-level or clip-level lists of rawframes, which can be used for ActivityNet Finetuning.
```shell
python generate_rawframes_filelist.py
```
### Step 5. Finetune TSN models on ActivityNet
You can use ActivityNet configs in `configs/recognition/tsn` to finetune TSN models on ActivityNet.
You need to use Kinetics models for pretraining.
Both RGB models and Flow models are supported.
### Step 6. Extract ActivityNet Feature with finetuned ckpts
After finetuning TSN on ActivityNet, you can use it to extract both RGB and Flow feature.
```shell
python ../../misc/clip_feature_extraction.py tsn_extract_rgb_feat_config.py \
/path/to/rgb_checkpoint.pth ../../../data/ActivityNet/rgb_tarin_feat.pkl \
--video-list ../../../data/ActivityNet/anet_train_video.txt \
--video-root ../../../data/ActivityNet/rawframes \
--dump-score
python ../../misc/clip_feature_extraction.py tsn_extract_rgb_feat_config.py \
path/to/rgb_checkpoint.pth ../../../data/ActivityNet/rgb_val_feat.pkl \
--video-list ../../../data/ActivityNet/anet_val_video.txt \
--video-root ../../../data/ActivityNet/rawframes \
--dump-score
python ../../misc/clip_feature_extraction.py tsn_extract_flow_feat_config.py \
/path/to/flow_checkpoint.pth ../../../data/ActivityNet/flow_tarin_feat.pkl \
--video-list ../../../data/ActivityNet/anet_train_video.txt \
--video-root ../../../data/ActivityNet/rawframes \
--dump-score
python ../../misc/clip_feature_extraction.py tsn_extract_flow_feat_config.py \
/path/to/flow_checkpoint.pth ../../../data/ActivityNet/flow_val_feat.pkl \
--video-list ../../../data/ActivityNet/anet_val_video.txt \
--video-root ../../../data/ActivityNet/rawframes \
--dump-score
```
After feature extraction, you can use our post processing scripts to concat RGB and Flow feature, generate the `100-t X 400-d` feature for Action Detection.
```shell
python activitynet_feature_postprocessing.py --rgb ../../../data/ActivityNet/rgb_feat --flow ../../../data/ActivityNet/flow_feat --dest ../../../data/ActivityNet/mmaction_feat
```
## Final Step. Check Directory Structure
After the whole data pipeline for ActivityNet preparation,
you will get the features, videos, frames and annotation files.
In the context of the whole project (for ActivityNet only), the folder structure will look like:
```
mmaction2
βββ mmaction
βββ tools
βββ configs
βββ data
β βββ ActivityNet
(if Option 1 used)
β β βββ anet_anno_{train,val,test,full}.json
β β βββ anet_anno_action.json
β β βββ video_info_new.csv
β β βββ activitynet_feature_cuhk
β β β βββ csv_mean_100
β β β β βββ v___c8enCfzqw.csv
β β β β βββ v___dXUJsj3yo.csv
β β β | βββ ..
(if Option 2 used)
β β βββ anet_train_video.txt
β β βββ anet_val_video.txt
β β βββ anet_train_clip.txt
β β βββ anet_val_clip.txt
β β βββ activity_net.v1-3.min.json
β β βββ mmaction_feat
β β β βββ v___c8enCfzqw.csv
β β β βββ v___dXUJsj3yo.csv
β β β βββ ..
β β βββ rawframes
β β β βββ v___c8enCfzqw
β β β β βββ img_00000.jpg
β β β β βββ flow_x_00000.jpg
β β β β βββ flow_y_00000.jpg
β β β β βββ ..
β β β βββ ..
```
For training and evaluating on ActivityNet, please refer to [Training and Test Tutorial](/docs/en/user_guides/train_test.md).
|