Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
282561270@qq.com e5c6627ee4 | 1 year ago | |
---|---|---|
scripts | 1 year ago | |
src | 1 year ago | |
README.md | 1 year ago | |
eval.py | 1 year ago | |
requriments.txt | 1 year ago | |
train.py | 1 year ago |
论文提出一种高效且用于通用视觉任务的基于 Transformer 的骨干网络,CSWin Transformer 。 CSWin Transformer
在常见的视觉任务上展示了非常好的性能。具体来说,它在没有任何额外训练数据或标签的情况下,在 ImageNet-1K 分类任务上达到了
85.4% Top-1 准确率,在 COCO 检测任务上达到了 53.9 box AP 和 46.4 mask AP,在 ADE20K 语义分割任务上达到了 51.7
mIOU,均超过了SwinT。通过在更大的数据集 ImageNet-21K 上进一步预训练,在 ImageNet-1K 上达到了 87.5% 的 Top-1 准确率,在
ADE20K 上达到了最先进的分割性能,达到了 55.7 mIoU。
使用的数据集:ImageNet2012
└─imagenet
├─train # 训练数据集
└─val # 评估数据集
采用混合精度
的训练方法,使用支持单精度和半精度数据来提高深度学习神经网络的训练速度,同时保持单精度训练所能达到的网络精度。混合精度训练提高计算速度、减少内存使用的同时,支持在特定硬件上训练更大的模型或实现更大批次的训练。
├── CSwin
│ ├── eval.py
│ ├── README.md
│ ├── requriments.txt
│ ├── scripts
│ │ ├── run_distribute_train_ascend.sh
│ │ ├── run_eval_ascend.sh
│ │ ├── run_infer_310.sh
│ │ └── run_standalone_train_ascend.sh
│ ├── src
│ │ ├── args.py
│ │ ├── configs
│ │ │ ├── CSWin_64_24322_small_224.yaml
│ │ │ ├── parser.py
│ │ │ └── __pycache__
│ │ │ └── parser.cpython-37.pyc
│ │ ├── data
│ │ │ ├── augment
│ │ │ │ ├── auto_augment.py
│ │ │ │ ├── __init__.py
│ │ │ │ ├── mixup.py
│ │ │ │ ├── random_erasing.py
│ │ │ │ └── transforms.py
│ │ │ ├── data_utils
│ │ │ │ ├── __init__.py
│ │ │ │ └── moxing_adapter.py
│ │ │ ├── imagenet.py
│ │ │ └── __init__.py
│ │ ├── models
│ │ │ ├── cswin.py
│ │ │ ├── initializer.py
│ │ │ ├── __init__.py
│ │ │ └── layers
│ │ │ ├── attention.py
│ │ │ ├── drop_path.py
│ │ │ └── identity.py
│ │ ├── tools
│ │ │ ├── callback.py
│ │ │ ├── cell.py
│ │ │ ├── criterion.py
│ │ │ ├── get_misc.py
│ │ │ ├── __init__.py
│ │ │ ├── optimizer.py
│ │ │ ├── schedulers.py
│ │ │ └── var_init.py
│ │ └── trainer
│ │ └── train_one_step.py
│ └── train.py
在CSWin_64_24322_small_224.yaml中可以同时配置训练参数和评估参数。
配置CSwin和ImageNet-1k数据集。
# Architecture 83.6%
arch: CSWin_64_24322_small_224
# ===== Dataset ===== #
data_url: ../data/imagenet
set: ImageNet
num_classes: 1000
mix_up: 0.8
cutmix: 1.0
auto_augment: rand-m9-mstd0.5-inc1
interpolation: bicubic
re_prob: 0.25
re_mode: pixel
re_count: 1
mixup_prob: 1.0
switch_prob: 0.5
mixup_mode: batch
image_size: 224
crop_pct: 0.9
# ===== Learning Rate Policy ======== #
optimizer: adamw
base_lr: 0.0005
warmup_lr: 0.000001
min_lr: 0.000001
lr_scheduler: cosine_lr
warmup_length: 20
# ===== Network training config ===== #
amp_level: O1
beta: [ 0.9, 0.999 ]
clip_global_norm_value: 5.
is_dynamic_loss_scale: True
epochs: 400
cooldown_epochs: 10
label_smoothing: 0.1
weight_decay: 0.05
momentum: 0.9
batch_size: 128
drop_path_rate: 0.5
# ===== Hardware setup ===== #
num_parallel_workers: 16
device_target: Ascend
更多配置细节请参考脚本CSWin_64_24322_small_224.yaml
。 通过官方网站安装MindSpore后,您可以按照如下步骤进行训练和评估:
Ascend处理器环境运行
# 使用python启动单卡训练
python train.py --device_id 0 --device_target Ascend --config ./src/configs/CSWin_64_24322_small_224.yaml \
> train.log 2>&1 &
# 使用脚本启动单卡训练
bash ./scripts/run_standalone_train_ascend.sh [DEVICE_ID] [CONFIG_PATH]
# 使用脚本启动多卡训练
bash ./scripts/run_distribute_train_ascend.sh [RANK_TABLE_FILE] [CONFIG_PATH]
# 使用python启动单卡运行评估示例
python eval.py --device_id 0 --device_target Ascend --config ./src/configs/CSWin_64_24322_small_224.yaml > ./eval.log 2>&1 &
# 使用脚本启动单卡运行评估示例
bash ./scripts/run_eval_ascend.sh [DEVICE_ID] [CONFIG_PATH] [CHECKPOINT_PATH]
对于分布式训练,需要提前创建JSON格式的hccl配置文件。
请遵循以下链接中的说明:
参数 | Ascend |
---|---|
模型 | CSwin |
模型版本 | CSWin_64_24322_small_224 |
资源 | Ascend 910 8卡 |
上传日期 | 2022-11-04 |
MindSpore版本 | 1.5.1 |
数据集 | ImageNet-1k Train,共1,281,167张图像 |
训练参数 | epoch=400, batch_size=1024 |
优化器 | AdamWeightDecay |
损失函数 | SoftTargetCrossEntropy |
损失 | 0.68 |
输出 | 概率 |
分类准确率 | 八卡:top1:83.67% top5:97.02% |
速度 | 8卡:702.446毫秒/步 |
训练耗时 | 104h30min03s(run on OpenI) |
请浏览官网主页
2022昇腾AI创新大赛昇思赛道 第一批 赛题三:利用MindSpore实现CSWin-Transformer图像分类网络
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》