Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add TSN dygraph model #4817

Open
wants to merge 7 commits into
base: release/1.8
Choose a base branch
from
Open

add TSN dygraph model #4817

wants to merge 7 commits into from

Conversation

LiuChaoXD
Copy link
Contributor

This PR

  • add TSN dygraph model

@CLAassistant
Copy link

CLAassistant commented Aug 26, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ root
❌ LiuChaoXD


root seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.


## 数据准备

TSN的训练数据采用由DeepMind公布的Kinetics-400动作识别数据集。数据下载及准备请参考[数据说明](./data/dataset/ucf101/README.md)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

【采用Kinetics-400动作识别数据集】,但数据说明链接给的是ucf-101?

@@ -0,0 +1,70 @@
# TSN 视频分类模型
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md VS REAMDE.md

```
单卡训练所使用的gpu可以通过如下方式设置:
- 首先,修改./configs/tsn.yaml 中的 num_gpus=1 (表示使用单卡进行训练)
- 首先,修改run.sh 中的 export CUDA_VISIBLE_DEVICES=0 (表示使用gpu 0 进行模型训练)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

两个首先,单卡时batch_size要调吗

@@ -0,0 +1,3783 @@
ApplyEyeMakeup/v_ApplyEyeMakeup_g01_c01.avi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove data list

@@ -0,0 +1,70 @@
# TSN 视频分类模型
本目录下为基于PaddlePaddle 动态图实现的 TSM视频分类模型
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TSM -> TSN


## 模型简介

Temporal Segment Network (TSN) 是视频分类领域经典的基于2D-CNN的解决方案。该方法主要解决视频的长时间行为判断问题,通过稀疏采样视频帧的方式代替稠密采样,既能捕获视频全局信息,也能去除冗余,降低计算量。最终将每帧特征平均融合后得到视频的整体特征,并用于分类。本代码实现的模型为基于单路RGB图像的TSN网络结构,Backbone采用ResNet-50结构。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResNet-50 -> ResNet50

bash multi-gpus-run.sh train ./configs/tsn.yaml
```
多卡训练所使用的gpu可以通过如下方式设置:
- 首先,修改./configs/tsn.yaml 中的 num_gpus (默认为4,表示使用4个gpu进行训练)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unnecessary to keep num_gpus in configuration, GPU_ID can be obtained by gpu_id = int(os.environ.get('FLAGS_selected_gpus', 0))

bash run.sh train ./configs/tsn.yaml
```
单卡训练所使用的gpu可以通过如下方式设置:
- 首先,修改./configs/tsn.yaml 中的 num_gpus=1 (表示使用单卡进行训练)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


- 使用`run.sh`进行评估时,需要修改脚本中的`weights`参数指定需要评估的权重

- `./tsn-test.yaml` 是评估模型时所用的参数文件;`./weights/final.pdparams` 为模型训练完成后,保存的模型文件
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use underline instead of dash name files

y = fluid.layers.elementwise_add(x=short, y=conv2)
return fluid.layers.relu(y)

# layer_helper = LayerHelper(self.full_name(), act="relu")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@@ -0,0 +1,81 @@
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2020

@@ -0,0 +1,905 @@
# copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

support frames and video

strategy)

bs_denominator = 1
if args.use_gpu:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as remove gpu num

"_" + model_path_pre + "_epoch{}".format(epoch))
fluid.dygraph.save_dygraph(video_model.state_dict(), model_path)
fluid.dygraph.save_dygraph(optimizer.state_dict(), model_path)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if validate

UCF101数据的详细信息可以参考网站[UCF101](https://www.crcv.ucf.edu/data/UCF101.php)。 为了方便用户使用,我们提供了UCF101数据的annotations文件和videos文件的下载脚本。

### 下载annotations文件
首先,请确保在`./data/dataset/ucf101/`目录下,输入如下UCF101数据集的标注文件的命令。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

输入如下命令下载UCF101数据集的标注文件。

生成视频文件的路径list,输入如下命令

```python
python build_ucf101_file_list.py videos/ --level 2 --format videos --out_list_path ./
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(1) 生成list的时候建议不要shuffle,在Reader里做shuffle
(2) 最好直接生成绝对路径,Reader代码里不用再输入相对路径
(3) 可以示例一下生成的list文件内容

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants