Merge pull request #1795 from cuicheng01/add_cswin

add cswin code and doc
pull/1719/merge
cuicheng01 2022-03-30 17:56:03 +08:00 committed by GitHub
commit 91b5337fdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 2060 additions and 7 deletions

View File

@ -1,10 +1,11 @@
repos:
- repo: https://github.com/PaddlePaddle/mirrors-yapf.git
sha: 0d79c0c469bab64f7229c9aca2b1186ef47f0e37
rev: 0d79c0c469bab64f7229c9aca2b1186ef47f0e37
hooks:
- id: yapf
files: \.py$
- repo: https://github.com/pre-commit/pre-commit-hooks
sha: a11d9314b22d8f8c7556443875b731ef05965464
rev: a11d9314b22d8f8c7556443875b731ef05965464
hooks:
- id: check-merge-conflict
- id: check-symlinks
@ -15,7 +16,7 @@
- id: trailing-whitespace
files: \.md$
- repo: https://github.com/Lucas-C/pre-commit-hooks
sha: v1.0.1
rev: v1.0.1
hooks:
- id: forbid-crlf
files: \.md$

View File

@ -27,7 +27,9 @@
- [20. DLA series](#20)
- [21. RedNet series](#21)
- [22. TNT series](#22)
- [23. Other models](#23)
- [23. CSwinTransformer series](#23)
- [24. PVTV2 series](#24)
- [25. Other models](#25)
- [Reference](#reference)
<a name="1"></a>
@ -500,7 +502,40 @@ The accuracy and speed indicators of TNT series models are shown in the followin
<a name="23"></a>
## 23. Other models
## 23. CSWinTransformer series <sup>[[40](#ref40)]</sup>
The accuracy and speed indicators of CSWinTransformer series models are shown in the following table. For more introduction, please refer to: [CSWinTransformer series model documents](../models/CSWinTransformer_en.md)。
| Model | Top-1 Acc | Top-5 Acc | time(ms)<br>bs=1 | time(ms)<br>bs=4 | time(ms)<br/>bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address |
| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| CSWinTransformer_tiny_224 | 0.8281 | 0.9628 | - | - | - | 4.1 | 22 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_tiny_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_tiny_224_infer.tar) |
| CSWinTransformer_small_224 | 0.8358 | 0.9658 | - | - | - | 6.4 | 35 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_small_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_small_224_infer.tar) |
| CSWinTransformer_base_224 | 0.8420 | 0.9692 | - | - | - | 14.3 | 77 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_base_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_base_224_infer.tar) |
| CSWinTransformer_large_224 | 0.8643 | 0.9799 | - | - | - | 32.2 | 173.3 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_large_224_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_large_224_infer.tar) |
| CSWinTransformer_base_384 | 0.8550 | 0.9749 | - | - |- | 42.2 | 77 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_base_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_base_384_infer.tar) |
| CSWinTransformer_large_384 | 0.8748 | 0.9833 | - | - | - | 94.7 | 173.3 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_large_384_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_large_384_infer.tar) |
<a name="24"></a>
## 24. PVTV2 series <sup>[[41](#ref41)]</sup>
The accuracy and speed indicators of PVTV2 series models are shown in the following table. For more introduction, please refer to: [PVTV2 series model documents](../models/PVTV2_en.md)。
| Model | Top-1 Acc | Top-5 Acc | time(ms)<br>bs=1 | time(ms)<br>bs=4 | time(ms)<br/>bs=8 | FLOPs(G) | Params(M) | Pretrained Model Download Address | Inference Model Download Address |
| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| PVT_V2_B0 | 0.705 | 0.902 | - | - | - | 0.53 | 3.7 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B0_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B0_infer.tar) |
| PVT_V2_B1 | 0.787 | 0.945 | - | - | - | 2.0 | 14.0 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B1_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B1_infer.tar) |
| PVT_V2_B2 | 0.821 | 0.960 | - | - | - | 3.9 | 25.4 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B2_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B2_infer.tar) |
| PVT_V2_B2_Linear | 0.821 | 0.961 | - | - | - | 3.8 | 22.6 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B2_Linear_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B2_Linear_infer.tar) |
| PVT_V2_B3 | 0.831 | 0.965 | - | - |- | 6.7 | 45.2 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B3_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B3_infer.tar) |
| PVT_V2_B4 | 0.836 | 0.967 | - | - | - | 9.8 | 62.6 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B4_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B4_infer.tar) |
| PVT_V2_B5 | 0.837 | 0.966 | - | - | - | 11.4 | 82.0 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B5_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B5_infer.tar) |
<a name="25"></a>
## 25. Other models
The accuracy and speed indicators of AlexNet <sup>[[18](#ref18)]</sup>, SqueezeNet series <sup>[[19](#ref19)]</sup>, VGG series <sup>[[20](#ref20)]</sup>, DarkNet53 <sup>[[21](#ref21)]</sup> and other models are shown in the following table. For more information, please refer to: [Other model documents](../models/Others_en.md).
@ -597,3 +632,8 @@ TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE.
<a name="ref38">[38]</a>Fisher Yu, Dequan Wang, Evan Shelhamer, Trevor Darrell. Deep Layer Aggregation.
<a name="ref39">[39]</a>Duo Lim Jie Hu, Changhu Wang, Xiangtai Li, Qi She, Lei Zhu, Tong Zhang, Qifeng Chen. Involution: Inverting the Inherence of Convolution for Visual Recognition.
<a name="ref40">[40]</a>Xiaoyi Dong, Jianmin Bao, Dongdong Chen, Weiming Zhang, Nenghai Yu, Lu Yuan, Dong Chen, Baining Guo. CSWin Transformer: A General Vision Transformer Backbone with Cross-Shaped Windows.
<a name="ref41">[41]</a>Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao. PVTv2: Improved Baselines with Pyramid Vision Transformer.

View File

@ -0,0 +1,24 @@
# CSWinTransformer
---
## Catalogue
* [1. Overview](#1)
* [2. Accuracy, FLOPs and Parameters](#2)
<a name='1'></a>
## 1. Overview
CSWinTransformer is a new visual Transformer network that can be used as a general backbone network in the field of computer vision. CSWinTransformer proposes to do self-attention through a cross-shaped window, which not only has a very high computational efficiency, but also can obtain a global receptive field through two-layer calculation. CSWinTransformer also proposed a new encoding method: LePE, which further improved the accuracy of the model. [Paper](https://arxiv.org/abs/2107.00652)
<a name='2'></a>
## 2. Accuracy, FLOPs and Parameters
| Models | Top1 | Top5 | Reference<br>top1 | Reference<br>top5 | FLOPs<br>(G) | Params<br>(M) |
|:--:|:--:|:--:|:--:|:--:|:--:|:--:|
| CSWinTransformer_tiny_224 | 0.8281 | 0.9628 | 0.828 | - | 4.1 | 22 |
| CSWinTransformer_small_224 | 0.8358 | 0.9658 | 0.836 | - | 6.4 | 35 |
| CSWinTransformer_base_224 | 0.8420 | 0.9692 | 0.842 | - | 14.3 | 77 |
| CSWinTransformer_large_224 | 0.8643 | 0.9799 | 0.865 | - | 32.2 | 173.3 |
| CSWinTransformer_base_384 | 0.8550 | 0.9749 | 0.855 | - | 42.2 | 77 |
| CSWinTransformer_large_384 | 0.8748 | 0.9833 | 0.875 | - | 94.7 | 173.3 |

View File

@ -30,7 +30,9 @@
- [20. DLA 系列](#20)
- [21. RedNet 系列](#21)
- [22. TNT 系列](#22)
- [23. 其他模型](#23)
- [23. CSwinTransformer 系列](#23)
- [24. PVTV2 系列](#24)
- [25. 其他模型](#25)
- [参考文献](#reference)
<a name="1"></a>
@ -500,7 +502,41 @@ ViT(Vision Transformer) 与 DeiTData-efficient Image Transformers系列模
<a name="23"></a>
## 23. 其他模型
## 23. CSWinTransformer 系列 <sup>[[40](#ref40)]</sup>
关于 CSWinTransformer 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[CSWinTransformer 系列模型文档](../models/CSWinTransformer.md)。
| 模型 | Top-1 Acc | Top-5 Acc | time(ms)<br>bs=1 | time(ms)<br>bs=4 | time(ms)<br/>bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 |
| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| CSWinTransformer_tiny_224 | 0.8281 | 0.9628 | - | - | - | 4.1 | 22 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_tiny_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_tiny_224_infer.tar) |
| CSWinTransformer_small_224 | 0.8358 | 0.9658 | - | - | - | 6.4 | 35 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_small_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_small_224_infer.tar) |
| CSWinTransformer_base_224 | 0.8420 | 0.9692 | - | - | - | 14.3 | 77 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_base_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_base_224_infer.tar) |
| CSWinTransformer_large_224 | 0.8643 | 0.9799 | - | - | - | 32.2 | 173.3 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_large_224_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_large_224_infer.tar) |
| CSWinTransformer_base_384 | 0.8550 | 0.9749 | - | - |- | 42.2 | 77 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_base_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_base_384_infer.tar) |
| CSWinTransformer_large_384 | 0.8748 | 0.9833 | - | - | - | 94.7 | 173.3 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_large_384_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/CSWinTransformer_large_384_infer.tar) |
<a name="24"></a>
## 24. PVTV2 系列 <sup>[[41](#ref41)]</sup>
关于 PVTV2 系列模型的精度、速度指标如下表所示,更多介绍可以参考:[PVTV2 系列模型文档](../models/PVTV2.md)。
| 模型 | Top-1 Acc | Top-5 Acc | time(ms)<br>bs=1 | time(ms)<br>bs=4 | time(ms)<br/>bs=8 | FLOPs(G) | Params(M) | 预训练模型下载地址 | inference模型下载地址 |
| ---------- | --------- | --------- | ---------------- | ---------------- | -------- | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| PVT_V2_B0 | 0.705 | 0.902 | - | - | - | 0.53 | 3.7 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B0_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B0_infer.tar) |
| PVT_V2_B1 | 0.787 | 0.945 | - | - | - | 2.0 | 14.0 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B1_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B1_infer.tar) |
| PVT_V2_B2 | 0.821 | 0.960 | - | - | - | 3.9 | 25.4 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B2_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B2_infer.tar) |
| PVT_V2_B2_Linear | 0.821 | 0.961 | - | - | - | 3.8 | 22.6 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B2_Linear_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B2_Linear_infer.tar) |
| PVT_V2_B3 | 0.831 | 0.965 | - | - |- | 6.7 | 45.2 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B3_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B3_infer.tar) |
| PVT_V2_B4 | 0.836 | 0.967 | - | - | - | 9.8 | 62.6 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B4_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B4_infer.tar) |
| PVT_V2_B5 | 0.837 | 0.966 | - | - | - | 11.4 | 82.0 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/PVT_V2_B5_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PVT_V2_B5_infer.tar) |
<a name="25"></a>
## 25. 其他模型
关于 AlexNet <sup>[[18](#ref18)]</sup>、SqueezeNet 系列 <sup>[[19](#ref19)]</sup>、VGG 系列 <sup>[[20](#ref20)]</sup>、DarkNet53 <sup>[[21](#ref21)]</sup> 等模型的精度、速度指标如下表所示,更多介绍可以参考:[其他模型文档](../models/Others.md)。
@ -597,3 +633,7 @@ TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE.
<a name="ref38">[38]</a>Fisher Yu, Dequan Wang, Evan Shelhamer, Trevor Darrell. Deep Layer Aggregation.
<a name="ref39">[39]</a>Duo Lim Jie Hu, Changhu Wang, Xiangtai Li, Qi She, Lei Zhu, Tong Zhang, Qifeng Chen. Involution: Inverting the Inherence of Convolution for Visual Recognition.
<a name="ref40">[40]</a>Xiaoyi Dong, Jianmin Bao, Dongdong Chen, Weiming Zhang, Nenghai Yu, Lu Yuan, Dong Chen, Baining Guo. CSWin Transformer: A General Vision Transformer Backbone with Cross-Shaped Windows.
<a name="ref41">[41]</a>Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, Ling Shao. PVTv2: Improved Baselines with Pyramid Vision Transformer.

View File

@ -0,0 +1,24 @@
# CSWinTransformer
---
## 目录
* [1. 概述](#1)
* [2. 精度、FLOPs 和参数量](#2)
<a name='1'></a>
## 1. 概述
CSWinTransformer 是一种新的视觉 Transformer 网络,可以用作计算机视觉领域的通用骨干网路。 CSWinTransformer 提出了通过十字形的窗口来做 self-attention它不仅计算效率非常高而且能够通过两层计算就获得全局的感受野。CSWinTransformer 还提出了新的编码方式LePE进一步提高了模型的准确率。[论文地址](https://arxiv.org/abs/2107.00652)。
<a name='2'></a>
## 2. 精度、FLOPs 和参数量
| Models | Top1 | Top5 | Reference<br>top1 | Reference<br>top5 | FLOPs<br>(G) | Params<br>(M) |
|:--:|:--:|:--:|:--:|:--:|:--:|:--:|
| CSWinTransformer_tiny_224 | 0.8281 | 0.9628 | 0.828 | - | 4.1 | 22 |
| CSWinTransformer_small_224 | 0.8358 | 0.9658 | 0.836 | - | 6.4 | 35 |
| CSWinTransformer_base_224 | 0.8420 | 0.9692 | 0.842 | - | 14.3 | 77 |
| CSWinTransformer_large_224 | 0.8643 | 0.9799 | 0.865 | - | 32.2 | 173.3 |
| CSWinTransformer_base_384 | 0.8550 | 0.9749 | 0.855 | - | 42.2 | 77 |
| CSWinTransformer_large_384 | 0.8748 | 0.9833 | 0.875 | - | 94.7 | 173.3 |

View File

@ -51,6 +51,7 @@ from ppcls.arch.backbone.model_zoo.regnet import RegNetX_200MF, RegNetX_4GF, Reg
from ppcls.arch.backbone.model_zoo.vision_transformer import ViT_small_patch16_224, ViT_base_patch16_224, ViT_base_patch16_384, ViT_base_patch32_384, ViT_large_patch16_224, ViT_large_patch16_384, ViT_large_patch32_384
from ppcls.arch.backbone.model_zoo.distilled_vision_transformer import DeiT_tiny_patch16_224, DeiT_small_patch16_224, DeiT_base_patch16_224, DeiT_tiny_distilled_patch16_224, DeiT_small_distilled_patch16_224, DeiT_base_distilled_patch16_224, DeiT_base_patch16_384, DeiT_base_distilled_patch16_384
from ppcls.arch.backbone.model_zoo.swin_transformer import SwinTransformer_tiny_patch4_window7_224, SwinTransformer_small_patch4_window7_224, SwinTransformer_base_patch4_window7_224, SwinTransformer_base_patch4_window12_384, SwinTransformer_large_patch4_window7_224, SwinTransformer_large_patch4_window12_384
from ppcls.arch.backbone.model_zoo.cswin_transformer import CSWinTransformer_tiny_224, CSWinTransformer_small_224, CSWinTransformer_base_224, CSWinTransformer_large_224, CSWinTransformer_base_384, CSWinTransformer_large_384
from ppcls.arch.backbone.model_zoo.mixnet import MixNet_S, MixNet_M, MixNet_L
from ppcls.arch.backbone.model_zoo.rexnet import ReXNet_1_0, ReXNet_1_3, ReXNet_1_5, ReXNet_2_0, ReXNet_3_0
from ppcls.arch.backbone.model_zoo.gvt import pcpvt_small, pcpvt_base, pcpvt_large, alt_gvt_small, alt_gvt_base, alt_gvt_large

View File

@ -0,0 +1,650 @@
# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Code was based on https://github.com/BR-IDL/PaddleViT/blob/develop/image_classification/CSwin/cswin.py
import copy
import numpy as np
import paddle
import paddle.nn as nn
from .vision_transformer import trunc_normal_, zeros_, ones_, to_2tuple, DropPath, Identity
from ppcls.utils.save_load import load_dygraph_pretrain, load_dygraph_pretrain_from_url
MODEL_URLS = {
"CSWinTransformer_tiny_224":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_tiny_224_pretrained.pdparams",
"CSWinTransformer_small_224":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_small_224_pretrained.pdparams",
"CSWinTransformer_base_224":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_base_224_pretrained.pdparams",
"CSWinTransformer_large_224":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_large_224_pretrained.pdparams",
"CSWinTransformer_base_384":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_base_384_pretrained.pdparams",
"CSWinTransformer_large_384":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_large_384_pretrained.pdparams",
}
__all__ = list(MODEL_URLS.keys())
class PatchEmbedding(nn.Layer):
"""CSwin Patch Embedding
This patch embedding has a 7x7 conv + layernorm, the output tensor
is reshaped to [Batch, H*W, embed_dim]. Note that the patch is applied
by a conv with overlap (using patch_stride).
Args:
patch_stride: int, patch stride size, default: 4
in_channels: int, number of channels of input image, default: 3
embed_dim: int, output feature dimension, default: 96
"""
def __init__(self, patch_stride=4, in_channels=3, embed_dim=96):
super().__init__()
self.patch_embed = nn.Conv2D(
in_channels=in_channels,
out_channels=embed_dim,
kernel_size=7,
stride=patch_stride,
padding=2)
self.norm = nn.LayerNorm(embed_dim)
def forward(self, x):
x = self.patch_embed(
x) # [batch, embed_dim, h, w], h = w = image_size / 4
x = x.flatten(start_axis=2, stop_axis=-1) # [batch, embed_dim, h*w]
x = x.transpose([0, 2, 1]) # [batch, h*w, embed_dim]
x = self.norm(x)
return x
class Mlp(nn.Layer):
""" MLP module
Impl using nn.Linear and activation is GELU, dropout is applied.
Ops: fc -> act -> dropout -> fc -> dropout
Attributes:
fc1: nn.Linear
fc2: nn.Linear
act: GELU
dropout1: dropout after fc1
dropout2: dropout after fc2
"""
def __init__(self, in_features, hidden_features, dropout):
super().__init__()
self.fc1 = nn.Linear(in_features, hidden_features)
self.fc2 = nn.Linear(hidden_features, in_features)
self.act = nn.GELU()
self.dropout = nn.Dropout(dropout)
def forward(self, x):
x = self.fc1(x)
x = self.act(x)
x = self.dropout(x)
x = self.fc2(x)
x = self.dropout(x)
return x
def img2windows(img, h_split, w_split):
"""Convert input tensor into split stripes
Args:
img: tensor, image tensor with shape [B, C, H, W]
h_split: int, splits width in height direction
w_split: int, splits width in width direction
Returns:
out: tensor, splitted image
"""
B, C, H, W = img.shape
out = img.reshape([B, C, H // h_split, h_split, W // w_split, w_split])
out = out.transpose(
[0, 2, 4, 3, 5, 1]) # [B, H//h_split, W//w_split, h_split, w_split, C]
out = out.reshape([-1, h_split * w_split,
C]) # [B, H//h_split, W//w_split, h_split*w_split, C]
return out
def windows2img(img_splits, h_split, w_split, img_h, img_w):
"""Convert splitted stripes back
Args:
img_splits: tensor, image tensor with shape [B, C, H, W]
h_split: int, splits width in height direction
w_split: int, splits width in width direction
img_h: int, original tensor height
img_w: int, original tensor width
Returns:
img: tensor, original tensor
"""
B = paddle.to_tensor(img_splits.shape[0] //
(img_h // h_split * img_w // w_split), "int32")
img = img_splits.reshape([
B, img_h // h_split, img_w // w_split, h_split, w_split,
img_splits.shape[-1]
])
img = img.transpose(
[0, 1, 3, 2, 4,
5]) #[B,img_h//h_split, h_split, img_w//w_split, w_split,C]
img = img.reshape(
[B, img_h, img_w, img_splits.shape[-1]]) # [B, img_h, img_w, C]
return img
class LePEAttention(nn.Layer):
"""Cross Shaped Window self-attention with Locally enhanced positional encoding"""
def __init__(self,
dim,
resolution,
h_split=7,
w_split=7,
num_heads=8,
attention_dropout=0.,
dropout=0.,
qk_scale=None):
super().__init__()
self.dim = dim
self.resolution = resolution
self.num_heads = num_heads
self.dim_head = dim // num_heads
self.scale = qk_scale or self.dim_head**-0.5
self.h_split = h_split
self.w_split = w_split
self.get_v = nn.Conv2D(
in_channels=dim,
out_channels=dim,
kernel_size=3,
stride=1,
padding=1,
groups=dim)
self.softmax = nn.Softmax(axis=-1)
self.attn_dropout = nn.Dropout(attention_dropout)
def im2cswin(self, x):
B, HW, C = x.shape
H = W = int(np.sqrt(HW))
x = x.transpose([0, 2, 1]) # [B, C, H*W]
x = x.reshape([B, C, H, W]) # [B, C, H, W]
x = img2windows(x, self.h_split, self.w_split)
x = x.reshape(
[-1, self.h_split * self.w_split, self.num_heads, self.dim_head])
x = x.transpose([0, 2, 1, 3])
return x
def get_lepe(self, x, func):
"""Locally Enhanced Positional Encoding (LePE)
This module applies a depthwise conv on V and returns the lepe
Args:
x: tensor, the input tensor V
func: nn.Layer, a depth wise conv of kernel 3 stride 1 and padding 1
"""
B, HW, C = x.shape
H = W = int(np.sqrt(HW))
h_split = self.h_split
w_split = self.w_split
x = x.transpose([0, 2, 1]) # [B, C, H*W]
x = x.reshape([B, C, H, W]) # [B, C, H, W]
x = x.reshape([B, C, H // h_split, h_split, W // w_split, w_split])
x = x.transpose(
[0, 2, 4, 1, 3,
5]) # [B, H//h_split, W//w_split, C, h_split, w_split]
x = x.reshape(
[-1, C, h_split,
w_split]) # [B*(H//h_split)*(W//w_split), h_split, w_split]
lepe = func(x) # depth wise conv does not change shape
#lepe = lepe.reshape([-1, self.num_heads, C // self.num_heads, h_split * w_split])
lepe = lepe.reshape(
[-1, self.num_heads, self.dim_head, h_split * w_split])
lepe = lepe.transpose(
[0, 1, 3, 2]) # [B, num_heads, h_spllit*w_split, dim_head]
x = x.reshape([-1, self.num_heads, self.dim_head, h_split * w_split])
x = x.transpose(
[0, 1, 3, 2]) # [B, num_heads, h_split*wsplit, dim_head]
return x, lepe
def forward(self, q, k, v):
B, HW, C = q.shape
H = W = self.resolution
q = self.im2cswin(q)
k = self.im2cswin(k)
v, lepe = self.get_lepe(v, self.get_v)
q = q * self.scale
attn = paddle.matmul(q, k, transpose_y=True)
attn = self.softmax(attn)
attn = self.attn_dropout(attn)
z = paddle.matmul(attn, v)
z = z + lepe
z = z.transpose([0, 2, 1, 3])
z = z.reshape([-1, self.h_split * self.w_split, C])
z = windows2img(z, self.h_split, self.w_split, H, W)
z = z.reshape([B, z.shape[1] * z.shape[2], C])
return z
class CSwinBlock(nn.Layer):
"""CSwin Block
CSwin block contains a LePE attention modual, a linear projection,
a mlp layer, and related norms layers. In the first 3 stages, the
LePE attention moduals used 2 branches, where horizontal and
vertical split stripes are used for self attention and a concat
op is applied to combine the outputs. The last stage does not
have branche in LePE attention.
Args:
dim: int, input feature dimension
input_resolution: int, input feature spatial size.
num_heads: int, num of attention heads in current stage
split_size: int, the split size in current stage
mlp_ratio: float, mlp ratio, mlp_hidden_dim = mlp_ratio * mlp_in_dim, default: 4.
qkv_bias: bool, if set True, qkv projection will have bias, default: True
qk_scale: float, if set, replace the orig qk_scale (dim_head ** -0.5), default: None
dropout: float, dropout rate for linear projection, default: 0
attention_dropout: float, dropout rate for attention, default: 0
droppath: float, drop path rate, default: 0
split_heads: bool, if True, split heads is applied (True for 1,2,3 stages), default: True
"""
def __init__(self,
dim,
input_resolution,
num_heads,
split_size=7,
mlp_ratio=4.,
qkv_bias=False,
qk_scale=None,
attention_dropout=0.,
dropout=0.,
droppath=0.,
split_heads=True):
super().__init__()
self.dim = dim
# NOTE: here assume image_h == imgae_w
self.input_resolution = (input_resolution, input_resolution)
self.num_heads = num_heads
self.dim_head = dim // num_heads
self.mlp_ratio = mlp_ratio
self.split_size = split_size
self.norm1 = nn.LayerNorm(dim)
self.qkv = nn.Linear(
dim, dim * 3, bias_attr=None if qkv_bias else False)
self.attns = nn.LayerList()
self.split_heads = split_heads
num_branches = 2 if split_heads else 1
if split_heads: # first 3 stages
splits = [self.input_resolution[0],
self.split_size] # horizantal splits
else: # last stage
splits = [self.input_resolution[0], self.input_resolution[0]]
for _ in range(num_branches):
attn = LePEAttention(
dim=dim // num_branches,
resolution=input_resolution,
h_split=splits[0],
w_split=splits[1],
num_heads=num_heads // num_branches,
qk_scale=qk_scale,
attention_dropout=attention_dropout,
dropout=dropout)
self.attns.append(copy.deepcopy(attn))
# switch splits from horizantal to vertical
# NOTE: may need to change for different H and W
splits[0], splits[1] = splits[1], splits[0]
self.proj = nn.Linear(dim, dim)
self.drop_path = DropPath(droppath) if droppath > 0. else Identity()
self.norm2 = nn.LayerNorm(dim)
self.mlp = Mlp(in_features=dim,
hidden_features=int(dim * mlp_ratio),
dropout=dropout)
def chunk_qkv(self, x, chunks=1, axis=-1):
x = x.chunk(chunks, axis=axis)
return x
def forward(self, x):
H, W = self.input_resolution
B, HW, C = x.shape
# cswin attention
h = x
x = self.norm1(x)
qkv = self.qkv(x).chunk(3, axis=-1) # qkv is a tuple of [q, k, v]
if self.split_heads:
q, k, v = map(self.chunk_qkv, qkv,
(2, 2, 2)) # map requries list/tuple inputs
else:
q, k, v = map(lambda x: [x], qkv)
if self.split_heads: # first 3 stages
h_attn = self.attns[0](q[0], k[0], v[0])
w_attn = self.attns[1](q[1], k[1], v[1])
attn = paddle.concat([h_attn, w_attn], axis=2)
else: # last stage
attn = self.attns[0](q[0], k[0], v[0])
attn = self.proj(attn)
attn = self.drop_path(attn)
x = h + attn
# mlp + residual
h = x
x = self.norm2(x)
x = self.mlp(x)
x = self.drop_path(x)
x = h + x
return x
class MergeBlock(nn.Layer):
def __init__(self, dim_in, dim_out):
super().__init__()
self.conv = nn.Conv2D(
in_channels=dim_in,
out_channels=dim_out,
kernel_size=3,
stride=2,
padding=1)
self.norm = nn.LayerNorm(dim_out)
def forward(self, x):
B, HW, C = x.shape
H = W = int(np.sqrt(HW))
x = x.transpose([0, 2, 1]) # [B, C, HW]
x = x.reshape([B, C, H, W]) # [B, C, H, W]
x = self.conv(x)
new_shape = [x.shape[0], x.shape[1],
x.shape[2] * x.shape[3]] # [B, C', H*W]
x = x.reshape(new_shape) # [B, C', H*W]
x = x.transpose([0, 2, 1]) # [B, H*W, C']
x = self.norm(x)
return x
class CSwinStage(nn.Layer):
""" CSwin Stage, each stage contains multi blocks
CSwin has 4 stages, the first 3 stages are using head split. The last
stage does not have head split. There is a merge block between each
2 stages.
Args:
dim: int, input feature dimension
depth: int, number of blocks in current stage
num_heads: int, num of attention heads in current stage
split_size: int, the split size in current stage
mlp_ratio: float, mlp ratio, mlp_hidden_dim = mlp_ratio * mlp_in_dim, default: 4.
qkv_bias: bool, if set True, qkv projection will have bias, default: True
qk_scale: float, if set, replace the orig qk_scale (dim_head ** -0.5), default: None
dropout: float, dropout rate for linear projection, default: 0
attention_dropout: float, dropout rate for attention, default: 0
droppath: float, drop path rate, default: 0
last_stage: bool, if current stage is the last stage, default: False
"""
def __init__(self,
dim,
input_resolution,
depth,
num_heads,
split_size,
mlp_ratio=4.,
qkv_bias=True,
qk_scale=None,
dropout=0.,
attention_dropout=0.,
droppath=0.,
last_stage=False):
super().__init__()
self.blocks = nn.LayerList()
for i in range(depth):
block = CSwinBlock(
dim=dim,
input_resolution=input_resolution,
num_heads=num_heads,
split_size=split_size,
mlp_ratio=mlp_ratio,
qkv_bias=qkv_bias,
qk_scale=qk_scale,
attention_dropout=attention_dropout,
dropout=dropout,
droppath=droppath[i]
if isinstance(droppath, list) else droppath,
split_heads=not last_stage)
self.blocks.append(copy.deepcopy(block))
# last stage does not need merge layer
self.merge = MergeBlock(
dim_in=dim, dim_out=dim * 2) if not last_stage else Identity()
def forward(self, x):
for block in self.blocks:
x = block(x)
x = self.merge(x)
return x
class CSwinTransformer(nn.Layer):
"""CSwin Transformer class
Args:
image_size: int, input image size, default: 224
patch_stride: int, stride for patch embedding, default: 4
in_channels: int, num of channels of input image, default: 3
num_classes: int, num of classes, default: 1000
embed_dim: int, embedding dim (patch embed out dim), default: 96
depths: list/tuple(int), number of blocks in each stage, default: [2, 4, 32, 2]
splits: list/tuple(int), the split number in each stage, default: [1, 2, 7, 7]
num_heads: list/tuple(int), num of attention heads in each stage, default: [4, 8, 16, 32]
mlp_ratio: float, mlp ratio, mlp_hidden_dim = mlp_ratio * mlp_in_dim, default: 4.
qkv_bias: bool, if set True, qkv projection will have bias, default: True
qk_scale: float, if set, replace the orig qk_scale (dim_head ** -0.5), default: None
dropout: float, dropout rate for linear projection, default: 0
attention_dropout: float, dropout rate for attention, default: 0
droppath: float, drop path rate, default: 0
"""
def __init__(self,
image_size=224,
patch_stride=4,
in_channels=3,
class_num=1000,
embed_dim=96,
depths=[2, 4, 32, 2],
splits=[1, 2, 7, 7],
num_heads=[4, 8, 16, 32],
mlp_ratio=4.,
qkv_bias=True,
qk_scale=None,
dropout=0.,
attention_dropout=0.,
droppath=0.):
super().__init__()
# token embedding
self.patch_embedding = PatchEmbedding(
patch_stride=patch_stride,
in_channels=in_channels,
embed_dim=embed_dim)
# drop path decay by stage
depth_decay = [
x.item() for x in paddle.linspace(0, droppath, sum(depths))
]
dim = embed_dim
resolution = image_size // 4
self.stages = nn.LayerList()
num_stages = len(depths)
# construct CSwin stages: each stage has multiple blocks
for stage_idx in range(num_stages):
stage = CSwinStage(
dim=dim,
input_resolution=resolution,
depth=depths[stage_idx],
num_heads=num_heads[stage_idx],
split_size=splits[stage_idx],
mlp_ratio=mlp_ratio,
qkv_bias=qkv_bias,
qk_scale=qk_scale,
dropout=dropout,
attention_dropout=attention_dropout,
droppath=depth_decay[sum(depths[:stage_idx]):sum(
depths[:stage_idx + 1])],
last_stage=stage_idx == num_stages - 1)
self.stages.append(stage)
if stage_idx != num_stages - 1:
dim = dim * 2
resolution = resolution // 2
# last norm and classification head layers
self.norm = nn.LayerNorm(dim)
self.head = nn.Linear(dim, class_num)
self.apply(self._init_weights)
def _init_weights(self, m):
if isinstance(m, nn.Linear):
trunc_normal_(m.weight)
if isinstance(m, nn.Linear) and m.bias is not None:
zeros_(m.bias)
elif isinstance(m, nn.LayerNorm):
zeros_(m.bias)
ones_(m.weight)
def forward_features(self, x):
x = self.patch_embedding(x)
for stage in self.stages:
x = stage(x)
x = self.norm(x)
return paddle.mean(x, axis=1)
def forward(self, x):
x = self.forward_features(x)
x = self.head(x)
return x
def _load_pretrained(pretrained, model, model_url, use_ssld=False):
if pretrained is False:
pass
elif pretrained is True:
load_dygraph_pretrain_from_url(model, model_url, use_ssld=use_ssld)
elif isinstance(pretrained, str):
load_dygraph_pretrain(model, pretrained)
else:
raise RuntimeError(
"pretrained type is not available. Please use `string` or `boolean` type."
)
def CSWinTransformer_tiny_224(pretrained=False, use_ssld=False, **kwargs):
model = CSwinTransformer(
image_size=224,
embed_dim=64,
depths=[1, 2, 21, 1],
splits=[1, 2, 7, 7],
num_heads=[2, 4, 8, 16],
droppath=0.2,
**kwargs)
_load_pretrained(
pretrained,
model,
MODEL_URLS["CSWinTransformer_tiny_224"],
use_ssld=use_ssld)
return model
def CSWinTransformer_small_224(pretrained=False, use_ssld=False, **kwargs):
model = CSwinTransformer(
image_size=224,
embed_dim=64,
depths=[2, 4, 32, 2],
splits=[1, 2, 7, 7],
num_heads=[2, 4, 8, 16],
droppath=0.4,
**kwargs)
_load_pretrained(
pretrained,
model,
MODEL_URLS["CSWinTransformer_small_224"],
use_ssld=use_ssld)
return model
def CSWinTransformer_base_224(pretrained=False, use_ssld=False, **kwargs):
model = CSwinTransformer(
image_size=224,
embed_dim=96,
depths=[2, 4, 32, 2],
splits=[1, 2, 7, 7],
num_heads=[4, 8, 16, 32],
droppath=0.5,
**kwargs)
_load_pretrained(
pretrained,
model,
MODEL_URLS["CSWinTransformer_base_224"],
use_ssld=use_ssld)
return model
def CSWinTransformer_base_384(pretrained=False, use_ssld=False, **kwargs):
model = CSwinTransformer(
image_size=384,
embed_dim=96,
depths=[2, 4, 32, 2],
splits=[1, 2, 12, 12],
num_heads=[4, 8, 16, 32],
droppath=0.5,
**kwargs)
_load_pretrained(
pretrained,
model,
MODEL_URLS["CSWinTransformer_base_384"],
use_ssld=use_ssld)
return model
def CSWinTransformer_large_224(pretrained=False, use_ssld=False, **kwargs):
model = CSwinTransformer(
image_size=224,
embed_dim=144,
depths=[2, 4, 32, 2],
splits=[1, 2, 7, 7],
num_heads=[6, 12, 24, 24],
droppath=0.5,
**kwargs)
_load_pretrained(
pretrained,
model,
MODEL_URLS["CSWinTransformer_large_224"],
use_ssld=use_ssld)
return model
def CSWinTransformer_large_384(pretrained=False, use_ssld=False, **kwargs):
model = CSwinTransformer(
image_size=384,
embed_dim=144,
depths=[2, 4, 32, 2],
splits=[1, 2, 12, 12],
num_heads=[6, 12, 24, 24],
droppath=0.5,
**kwargs)
_load_pretrained(
pretrained,
model,
MODEL_URLS["CSWinTransformer_large_384"],
use_ssld=use_ssld)
return model

View File

@ -0,0 +1,161 @@
# global configs
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 300
print_batch_step: 10
use_visualdl: False
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
name: CSWinTransformer_base_224
class_num: 1000
# loss function config for traing/eval process
Loss:
Train:
- CELoss:
weight: 1.0
epsilon: 0.1
Eval:
- CELoss:
weight: 1.0
Optimizer:
name: AdamW
beta1: 0.9
beta2: 0.999
epsilon: 1e-8
weight_decay: 0.05
no_weight_decay_name: pos_embed cls_token .bias norm
one_dim_param_no_weight_decay: True
lr:
name: Cosine
learning_rate: 1.25e-4
eta_min: 1.25e-6
warmup_epoch: 20
warmup_start_lr: 1.25e-7
# data loader for train and eval
DataLoader:
Train:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- RandCropImage:
size: 224
interpolation: bicubic
backend: pil
- RandFlipImage:
flip_code: 1
- TimmAutoAugment:
config_str: rand-m9-mstd0.5-inc1
interpolation: bicubic
img_size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- RandomErasing:
EPSILON: 0.25
sl: 0.02
sh: 1.0/3.0
r1: 0.3
attempt: 10
use_log_aspect: True
mode: pixel
batch_transform_ops:
- OpSampler:
MixupOperator:
alpha: 0.8
prob: 0.5
CutmixOperator:
alpha: 1.0
prob: 0.5
sampler:
name: DistributedBatchSampler
batch_size: 32
drop_last: False
shuffle: True
loader:
num_workers: 4
use_shared_memory: True
Eval:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 248
interpolation: bicubic
backend: pil
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 128
drop_last: False
shuffle: False
loader:
num_workers: 4
use_shared_memory: True
Infer:
infer_imgs: docs/images/inference_deployment/whl_demo.jpg
batch_size: 10
transforms:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 248
interpolation: bicubic
backend: pil
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- ToCHWImage:
PostProcess:
name: Topk
topk: 5
class_id_map_file: ppcls/utils/imagenet1k_label_list.txt
Metric:
Eval:
- TopkAcc:
topk: [1, 5]

View File

@ -0,0 +1,160 @@
# global configs
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 300
print_batch_step: 10
use_visualdl: False
# used for static mode and model export
image_shape: [3, 384, 384]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
name: CSWinTransformer_base_384
class_num: 1000
# loss function config for traing/eval process
Loss:
Train:
- CELoss:
weight: 1.0
epsilon: 0.1
Eval:
- CELoss:
weight: 1.0
Optimizer:
name: AdamW
beta1: 0.9
beta2: 0.999
epsilon: 1e-8
weight_decay: 0.05
no_weight_decay_name: pos_embed cls_token .bias norm
one_dim_param_no_weight_decay: True
lr:
name: Cosine
learning_rate: 6.25e-5
eta_min: 6.25e-7
warmup_epoch: 20
warmup_start_lr: 6.25e-8
# data loader for train and eval
DataLoader:
Train:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- RandCropImage:
size: 384
interpolation: bicubic
backend: pil
- RandFlipImage:
flip_code: 1
- TimmAutoAugment:
config_str: rand-m9-mstd0.5-inc1
interpolation: bicubic
img_size: 384
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- RandomErasing:
EPSILON: 0.25
sl: 0.02
sh: 1.0/3.0
r1: 0.3
attempt: 10
use_log_aspect: True
mode: pixel
batch_transform_ops:
- OpSampler:
MixupOperator:
alpha: 0.8
prob: 0.5
CutmixOperator:
alpha: 1.0
prob: 0.5
sampler:
name: DistributedBatchSampler
batch_size: 16
drop_last: False
shuffle: True
loader:
num_workers: 4
use_shared_memory: True
Eval:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 384
interpolation: bicubic
backend: pil
- CropImage:
size: 384
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 64
drop_last: False
shuffle: False
loader:
num_workers: 4
use_shared_memory: True
Infer:
infer_imgs: docs/images/inference_deployment/whl_demo.jpg
batch_size: 10
transforms:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 384
interpolation: bicubic
backend: pil
- CropImage:
size: 384
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- ToCHWImage:
PostProcess:
name: Topk
topk: 5
class_id_map_file: ppcls/utils/imagenet1k_label_list.txt
Metric:
Eval:
- TopkAcc:
topk: [1, 5]

View File

@ -0,0 +1,160 @@
# global configs
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 300
print_batch_step: 10
use_visualdl: False
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
name: CSWinTransformer_large_224
class_num: 1000
# loss function config for traing/eval process
Loss:
Train:
- CELoss:
weight: 1.0
epsilon: 0.1
Eval:
- CELoss:
weight: 1.0
Optimizer:
name: AdamW
beta1: 0.9
beta2: 0.999
epsilon: 1e-8
weight_decay: 0.05
no_weight_decay_name: pos_embed cls_token .bias norm
one_dim_param_no_weight_decay: True
lr:
name: Cosine
learning_rate: 1.25e-4
eta_min: 1.25e-6
warmup_epoch: 20
warmup_start_lr: 1.25e-7
# data loader for train and eval
DataLoader:
Train:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- RandCropImage:
size: 224
interpolation: bicubic
backend: pil
- RandFlipImage:
flip_code: 1
- TimmAutoAugment:
config_str: rand-m9-mstd0.5-inc1
interpolation: bicubic
img_size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- RandomErasing:
EPSILON: 0.25
sl: 0.02
sh: 1.0/3.0
r1: 0.3
attempt: 10
use_log_aspect: True
mode: pixel
batch_transform_ops:
- OpSampler:
MixupOperator:
alpha: 0.8
prob: 0.5
CutmixOperator:
alpha: 1.0
prob: 0.5
sampler:
name: DistributedBatchSampler
batch_size: 32
drop_last: False
shuffle: True
loader:
num_workers: 4
use_shared_memory: True
Eval:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 248
interpolation: bicubic
backend: pil
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 128
drop_last: False
shuffle: False
loader:
num_workers: 4
use_shared_memory: True
Infer:
infer_imgs: docs/images/inference_deployment/whl_demo.jpg
batch_size: 10
transforms:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 248
interpolation: bicubic
backend: pil
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- ToCHWImage:
PostProcess:
name: Topk
topk: 5
class_id_map_file: ppcls/utils/imagenet1k_label_list.txt
Metric:
Eval:
- TopkAcc:
topk: [1, 5]

View File

@ -0,0 +1,160 @@
# global configs
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 300
print_batch_step: 10
use_visualdl: False
# used for static mode and model export
image_shape: [3, 384, 384]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
name: CSWinTransformer_large_384
class_num: 1000
# loss function config for traing/eval process
Loss:
Train:
- CELoss:
weight: 1.0
epsilon: 0.1
Eval:
- CELoss:
weight: 1.0
Optimizer:
name: AdamW
beta1: 0.9
beta2: 0.999
epsilon: 1e-8
weight_decay: 0.05
no_weight_decay_name: pos_embed cls_token .bias norm
one_dim_param_no_weight_decay: True
lr:
name: Cosine
learning_rate: 3.125e-5
eta_min: 3.125e-7
warmup_epoch: 20
warmup_start_lr: 3.125e-8
# data loader for train and eval
DataLoader:
Train:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- RandCropImage:
size: 384
interpolation: bicubic
backend: pil
- RandFlipImage:
flip_code: 1
- TimmAutoAugment:
config_str: rand-m9-mstd0.5-inc1
interpolation: bicubic
img_size: 384
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- RandomErasing:
EPSILON: 0.25
sl: 0.02
sh: 1.0/3.0
r1: 0.3
attempt: 10
use_log_aspect: True
mode: pixel
batch_transform_ops:
- OpSampler:
MixupOperator:
alpha: 0.8
prob: 0.5
CutmixOperator:
alpha: 1.0
prob: 0.5
sampler:
name: DistributedBatchSampler
batch_size: 8
drop_last: False
shuffle: True
loader:
num_workers: 4
use_shared_memory: True
Eval:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 384
interpolation: bicubic
backend: pil
- CropImage:
size: 384
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 64
drop_last: False
shuffle: False
loader:
num_workers: 4
use_shared_memory: True
Infer:
infer_imgs: docs/images/inference_deployment/whl_demo.jpg
batch_size: 10
transforms:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 384
interpolation: bicubic
backend: pil
- CropImage:
size: 384
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- ToCHWImage:
PostProcess:
name: Topk
topk: 5
class_id_map_file: ppcls/utils/imagenet1k_label_list.txt
Metric:
Eval:
- TopkAcc:
topk: [1, 5]

View File

@ -0,0 +1,160 @@
# global configs
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 300
print_batch_step: 10
use_visualdl: False
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
name: CSWinTransformer_small_224
class_num: 1000
# loss function config for traing/eval process
Loss:
Train:
- CELoss:
weight: 1.0
epsilon: 0.1
Eval:
- CELoss:
weight: 1.0
Optimizer:
name: AdamW
beta1: 0.9
beta2: 0.999
epsilon: 1e-8
weight_decay: 0.05
no_weight_decay_name: pos_embed cls_token .bias norm
one_dim_param_no_weight_decay: True
lr:
name: Cosine
learning_rate: 2.5e-4
eta_min: 2.5e-6
warmup_epoch: 20
warmup_start_lr: 2.5e-7
# data loader for train and eval
DataLoader:
Train:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- RandCropImage:
size: 224
interpolation: bicubic
backend: pil
- RandFlipImage:
flip_code: 1
- TimmAutoAugment:
config_str: rand-m9-mstd0.5-inc1
interpolation: bicubic
img_size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- RandomErasing:
EPSILON: 0.25
sl: 0.02
sh: 1.0/3.0
r1: 0.3
attempt: 10
use_log_aspect: True
mode: pixel
batch_transform_ops:
- OpSampler:
MixupOperator:
alpha: 0.8
prob: 0.5
CutmixOperator:
alpha: 1.0
prob: 0.5
sampler:
name: DistributedBatchSampler
batch_size: 64
drop_last: False
shuffle: True
loader:
num_workers: 4
use_shared_memory: True
Eval:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 248
interpolation: bicubic
backend: pil
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 128
drop_last: False
shuffle: False
loader:
num_workers: 4
use_shared_memory: True
Infer:
infer_imgs: docs/images/inference_deployment/whl_demo.jpg
batch_size: 10
transforms:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 248
interpolation: bicubic
backend: pil
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- ToCHWImage:
PostProcess:
name: Topk
topk: 5
class_id_map_file: ppcls/utils/imagenet1k_label_list.txt
Metric:
Eval:
- TopkAcc:
topk: [1, 5]

View File

@ -0,0 +1,160 @@
# global configs
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 300
print_batch_step: 10
use_visualdl: False
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
name: CSWinTransformer_tiny_224
class_num: 1000
# loss function config for traing/eval process
Loss:
Train:
- CELoss:
weight: 1.0
epsilon: 0.1
Eval:
- CELoss:
weight: 1.0
Optimizer:
name: AdamW
beta1: 0.9
beta2: 0.999
epsilon: 1e-8
weight_decay: 0.05
no_weight_decay_name: pos_embed cls_token .bias norm
one_dim_param_no_weight_decay: True
lr:
name: Cosine
learning_rate: 5e-4
eta_min: 5e-6
warmup_epoch: 20
warmup_start_lr: 5e-7
# data loader for train and eval
DataLoader:
Train:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- RandCropImage:
size: 224
interpolation: bicubic
backend: pil
- RandFlipImage:
flip_code: 1
- TimmAutoAugment:
config_str: rand-m9-mstd0.5-inc1
interpolation: bicubic
img_size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- RandomErasing:
EPSILON: 0.25
sl: 0.02
sh: 1.0/3.0
r1: 0.3
attempt: 10
use_log_aspect: True
mode: pixel
batch_transform_ops:
- OpSampler:
MixupOperator:
alpha: 0.8
prob: 0.5
CutmixOperator:
alpha: 1.0
prob: 0.5
sampler:
name: DistributedBatchSampler
batch_size: 128
drop_last: False
shuffle: True
loader:
num_workers: 4
use_shared_memory: True
Eval:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 248
interpolation: bicubic
backend: pil
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 128
drop_last: False
shuffle: False
loader:
num_workers: 4
use_shared_memory: True
Infer:
infer_imgs: docs/images/inference_deployment/whl_demo.jpg
batch_size: 10
transforms:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 248
interpolation: bicubic
backend: pil
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- ToCHWImage:
PostProcess:
name: Topk
topk: 5
class_id_map_file: ppcls/utils/imagenet1k_label_list.txt
Metric:
Eval:
- TopkAcc:
topk: [1, 5]

View File

@ -0,0 +1,52 @@
===========================train_params===========================
model_name:CSWinTransformer_base_224
python:python3.7
gpu_list:0|0,1
-o Global.device:gpu
-o Global.auto_cast:null
-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120
-o Global.output_dir:./output/
-o DataLoader.Train.sampler.batch_size:8
-o Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/ILSVRC2012/val
null:null
##
trainer:norm_train
norm_train:tools/train.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_base_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_base_224.yaml
null:null
##
===========================infer_params==========================
-o Global.save_inference_dir:./inference
-o Global.pretrained_model:
norm_export:tools/export_model.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_base_224.yaml
quant_export:null
fpgm_export:null
distill_export:null
kl_quant:null
export2:null
pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_base_224_pretrained.pdparams
infer_model:../inference/
infer_export:True
infer_quant:Fasle
inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=248
-o Global.use_gpu:True|False
-o Global.enable_mkldnn:True|False
-o Global.cpu_num_threads:1|6
-o Global.batch_size:1|16
-o Global.use_tensorrt:True|False
-o Global.use_fp16:True|False
-o Global.inference_model_dir:../inference
-o Global.infer_imgs:../dataset/ILSVRC2012/val
-o Global.save_log_path:null
-o Global.benchmark:True
null:null
null:null

View File

@ -0,0 +1,52 @@
===========================train_params===========================
model_name:CSWinTransformer_base_384
python:python3.7
gpu_list:0|0,1
-o Global.device:gpu
-o Global.auto_cast:null
-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120
-o Global.output_dir:./output/
-o DataLoader.Train.sampler.batch_size:8
-o Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/ILSVRC2012/val
null:null
##
trainer:norm_train
norm_train:tools/train.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_base_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_base_384.yaml
null:null
##
===========================infer_params==========================
-o Global.save_inference_dir:./inference
-o Global.pretrained_model:
norm_export:tools/export_model.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_base_384.yaml
quant_export:null
fpgm_export:null
distill_export:null
kl_quant:null
export2:null
pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_base_384_pretrained.pdparams
infer_model:../inference/
infer_export:True
infer_quant:Fasle
inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384
-o Global.use_gpu:True|False
-o Global.enable_mkldnn:True|False
-o Global.cpu_num_threads:1|6
-o Global.batch_size:1|16
-o Global.use_tensorrt:True|False
-o Global.use_fp16:True|False
-o Global.inference_model_dir:../inference
-o Global.infer_imgs:../dataset/ILSVRC2012/val
-o Global.save_log_path:null
-o Global.benchmark:True
null:null
null:null

View File

@ -0,0 +1,52 @@
===========================train_params===========================
model_name:CSWinTransformer_large_224
python:python3.7
gpu_list:0|0,1
-o Global.device:gpu
-o Global.auto_cast:null
-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120
-o Global.output_dir:./output/
-o DataLoader.Train.sampler.batch_size:8
-o Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/ILSVRC2012/val
null:null
##
trainer:norm_train
norm_train:tools/train.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_large_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_large_224.yaml
null:null
##
===========================infer_params==========================
-o Global.save_inference_dir:./inference
-o Global.pretrained_model:
norm_export:tools/export_model.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_large_224.yaml
quant_export:null
fpgm_export:null
distill_export:null
kl_quant:null
export2:null
pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_large_224_pretrained.pdparams
infer_model:../inference/
infer_export:True
infer_quant:Fasle
inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=248
-o Global.use_gpu:True|False
-o Global.enable_mkldnn:True|False
-o Global.cpu_num_threads:1|6
-o Global.batch_size:1|16
-o Global.use_tensorrt:True|False
-o Global.use_fp16:True|False
-o Global.inference_model_dir:../inference
-o Global.infer_imgs:../dataset/ILSVRC2012/val
-o Global.save_log_path:null
-o Global.benchmark:True
null:null
null:null

View File

@ -0,0 +1,52 @@
===========================train_params===========================
model_name:CSWinTransformer_large_384
python:python3.7
gpu_list:0|0,1
-o Global.device:gpu
-o Global.auto_cast:null
-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120
-o Global.output_dir:./output/
-o DataLoader.Train.sampler.batch_size:4
-o Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/ILSVRC2012/val
null:null
##
trainer:norm_train
norm_train:tools/train.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_large_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_large_384.yaml
null:null
##
===========================infer_params==========================
-o Global.save_inference_dir:./inference
-o Global.pretrained_model:
norm_export:tools/export_model.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_large_384.yaml
quant_export:null
fpgm_export:null
distill_export:null
kl_quant:null
export2:null
pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_large_384_pretrained.pdparams
infer_model:../inference/
infer_export:True
infer_quant:Fasle
inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384
-o Global.use_gpu:True|False
-o Global.enable_mkldnn:True|False
-o Global.cpu_num_threads:1|6
-o Global.batch_size:1|16
-o Global.use_tensorrt:True|False
-o Global.use_fp16:True|False
-o Global.inference_model_dir:../inference
-o Global.infer_imgs:../dataset/ILSVRC2012/val
-o Global.save_log_path:null
-o Global.benchmark:True
null:null
null:null

View File

@ -0,0 +1,52 @@
===========================train_params===========================
model_name:CSWinTransformer_small_224
python:python3.7
gpu_list:0|0,1
-o Global.device:gpu
-o Global.auto_cast:null
-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120
-o Global.output_dir:./output/
-o DataLoader.Train.sampler.batch_size:8
-o Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/ILSVRC2012/val
null:null
##
trainer:norm_train
norm_train:tools/train.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_small_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_small_224.yaml
null:null
##
===========================infer_params==========================
-o Global.save_inference_dir:./inference
-o Global.pretrained_model:
norm_export:tools/export_model.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_small_224.yaml
quant_export:null
fpgm_export:null
distill_export:null
kl_quant:null
export2:null
pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_small_224_pretrained.pdparams
infer_model:../inference/
infer_export:True
infer_quant:Fasle
inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=248
-o Global.use_gpu:True|False
-o Global.enable_mkldnn:True|False
-o Global.cpu_num_threads:1|6
-o Global.batch_size:1|16
-o Global.use_tensorrt:True|False
-o Global.use_fp16:True|False
-o Global.inference_model_dir:../inference
-o Global.infer_imgs:../dataset/ILSVRC2012/val
-o Global.save_log_path:null
-o Global.benchmark:True
null:null
null:null

View File

@ -0,0 +1,52 @@
===========================train_params===========================
model_name:CSWinTransformer_tiny_224
python:python3.7
gpu_list:0|0,1
-o Global.device:gpu
-o Global.auto_cast:null
-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120
-o Global.output_dir:./output/
-o DataLoader.Train.sampler.batch_size:8
-o Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/ILSVRC2012/val
null:null
##
trainer:norm_train
norm_train:tools/train.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_tiny_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_tiny_224.yaml
null:null
##
===========================infer_params==========================
-o Global.save_inference_dir:./inference
-o Global.pretrained_model:
norm_export:tools/export_model.py -c ppcls/configs/ImageNet/CSWinTransformer/CSWinTransformer_tiny_224.yaml
quant_export:null
fpgm_export:null
distill_export:null
kl_quant:null
export2:null
pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/CSWinTransformer_tiny_224_pretrained.pdparams
infer_model:../inference/
infer_export:True
infer_quant:Fasle
inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=248
-o Global.use_gpu:True|False
-o Global.enable_mkldnn:True|False
-o Global.cpu_num_threads:1|6
-o Global.batch_size:1|16
-o Global.use_tensorrt:True|False
-o Global.use_fp16:True|False
-o Global.inference_model_dir:../inference
-o Global.infer_imgs:../dataset/ILSVRC2012/val
-o Global.save_log_path:null
-o Global.benchmark:True
null:null
null:null