Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
LvanAI 097d0b1d3f | 1 year ago | |
---|---|---|
checkpoint | 1 year ago | |
class_file | 1 year ago | |
configs | 1 year ago | |
model_utils | 1 year ago | |
scripts | 1 year ago | |
src | 1 year ago | |
README.md | 1 year ago | |
eval.py | 1 year ago | |
requirements.txt | 1 year ago | |
train.py | 1 year ago |
时序关系网络( TRN )是一个解释网络模块,它允许在神经网络中进行时序关系推理,并旨在描述视频中观测之间的时序关系。TRN可以在多时间尺度上学习和发现可能的时间关系。TRN可以与任何现有的CNN架构(在这项工作中使用BN Inception)以即插即用的方式使用。
论文:
Zhou, Bolei & Andonian, Alex & Torralba, Antonio. (2017).
Temporal Relational Reasoning in Videos. arXiv:1711.08496v2 [cs.CV] 25 Jul 2018.
该模型使用了 BNInception 主干。最后一个全连接层由Dropout和FC层替代,以匹配从视频帧中提取特定数量的特征。TRN头由感知机层组成,感知机层从帧特征的不同组合中聚合特征。
可以直接使用基于原始论文提到的数据集或在相关领域广泛使用的数据集。
数据集 链接
登录后,需要下载包含视频帧数据和标签列表的24个ZIP存档。
文件结构是这样的:
JESTER/
├── 20bn-jester-download-package-labels.zip
├── 20bn-jester-v1-00.zip
├── … … …
├── 20bn-jester-v1-21.zip
└── 20bn-jester-v1-22.zip
对数据集进行解压,可以手动解压或使用脚本。 unpack_jester_dataset.sh
在模型文件的根目录运行
bash scripts/unpack_jester_dataset.sh [DATA_PATH] [TARGET_PATH]
例如:
bash scripts/unpack_jester_dataset.sh /path/to/JESTER /path/to/unpacked_JESTER
终端上的日志是这样的:
Target data folder: /path/to/unpacked_JESTER
Unzip...
…
Extract tar archives...
…
Remove unnecessary data...
…
DONE!
解压后的文件结构如下:
unpacked_JESTER/
├── 20bn-jester-v1/
│ ├── 1/
│ │ ├── 00001.jpg
│ │ ├── 00002.jpg
│ │ ├── …
│ │ └── 00037.jpg
│ ├── 2/
│ ├── 3/
│ ├── …
│ └── 148092/
└── labels/
├── labels.csv
├── test-answers.csv
├── test.csv
├── train.csv
└── validation.csv
使用此命令安装所需的包:
pip install -r requirements.txt
然后运行这个脚本 preprocess_jester_dataset.sh
:
bash scripts/preprocess_jester_dataset.sh [DATASET_ROOT]
例如:
bash scripts/preprocess_jester_dataset.sh /path/to/unpacked_JESTER
标准输出类似于:
dataset path: /path/to/unpacked_JESTER
labels path: /path/to/unpacked_JESTER/labels
labels save to: /path/to/unpacked_JESTER
Prepare training folders list
…
Prepare validation folders list
…
请确保您有权限写入数据集根目录。
运行之后,在数据集根目录中会得到三个新文件:
categories.txt
, train_videofolder.txt
, val_videofolder.txt
.
unpacked_JESTER/
├── 20bn-jester-v1/
├── labels/
├── categories.txt
├── train_videofolder.txt
└── val_videofolder.txt
硬件(Ascend)
框架
如需查看详情,请参见如下资源:
主干网络BNInception在ImageNet2012上预训练.
.
├── checkpoint # BN-Inception MindSpore模型
├── class_file # 训练集和验证集txt
├── configs # 模型配置文件
│ └── jester_config.yaml
├── model_utils # Model Arts相关函数
│ ├── __init__.py
│ ├── config.py
│ ├── device_adapter.py
│ ├── local_adapter.py
│ ├── logging.py
│ ├── moxing_adapter.py
│ └── util.py
├── scripts # 模型转换脚本
│ ├── convert_bn_inception.sh
│ ├── preprocess_jester_dataset.sh # 数据集预处理脚本
│ └── unpack_jester_dataset.sh # 数据集解压脚本
├── src # 模型及数据加载相关
│ ├── __init__.py
│ ├── bn_inception.py # 主干网络BN-inception定义
│ ├── convert_bn_inception.py # BN-inception模型转换
│ ├── preprocess_jester_dataset.py # 数据处理
│ ├── train_cell.py # 训练cell
│ ├── transforms.py # 数据增强及变换
│ ├── trn.py # TRN实现
│ ├── tsn.py # TSN
│ ├── tsn_dataset.py # 数据dataload
│ └── utils.py
├── eval.py # 性能评估
├── README.md
├── requirements.txt
└── train.py # 训练文件
训练和评估的参数都可以设置在 jester_config.yaml
默认配置fpr在JESTER数据集上训练TRN模型
# Example for the 8P training
# 模型参数配置
num_segments: 16 # 输入帧数
subsample_num: 8 # 每个TRN头的子样本数
# Dataset options
image_size: 224 # 用于调整输入图像的大小
img_feature_dim: 512 # Backbone 输出特征通道
# 训练参数配置
lr: 0.001 # 学习率
clip_grad_norm: 20.0 # 最大梯度范数
update_lr_epochs: 50 # 学习率更新前的epochs数
epochs_num: 140 # epochs 数
train_batch_size: 12 # 用于训练的批处理大小
momentum: 0.9 # 动量项
dropout: 0.2 # Dropout概率
weight_decay: 0.0005 # 权重衰减项
Ascend处理器环境运行
# 使用脚本启动多卡训练
mpirun -n 8 python train.py > train.log 2>&1 &
# 使用脚本启动单卡运行评估示例
python eval.py --config
参数 | Ascend 8p |
---|---|
模型 | TRN-MultiScale |
资源 | Ascend 910 |
上传日期 | 2022-10-30 |
MindSpore版本 | 1.7.0 |
数据集 | 20bn-Jester-v1 |
训练参数 | epoch=140, batch_size=12, lr=0.001 |
优化器 | SGD |
损失函数 | SoftmaxCrossEntropy |
速度 | 1616 ms/step |
训练耗时 | 78h 48m 2s |
参数 | Ascend 1p |
---|---|
模型 | TRN-MultiScale |
资源 | Ascend 910 |
上传时间 | 10/30/2022 |
MindSpore版本 | 1.7.0 |
数据集 | 20bn-Jester-v1 |
batch_size | 1 |
准确率 | Top1: 95.00%, Top5: 99.79% |
如果你想参与贡献昇思的工作当中,请阅读昇思贡献指南和how_to_contribute
2022昇腾AI创新大赛昇思赛道 第二批赛题七:利用MindSpore实现TRN视频分类网络
Text Python Shell
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》