# Swin Transformer (Tensorflow)
Tensorflow reimplementation of **Swin Transformer** model.
Based on [Official Pytorch implementation](https://github.com/microsoft/Swin-Transformer).
![image](https://user-images.githubusercontent.com/24825165/121768619-038e6d80-cb9a-11eb-8cb7-daa827e7772b.png)
## Requirements
- `tensorflow >= 2.4.1`
## Pretrained Swin Transformer Checkpoints
**ImageNet-1K and ImageNet-22K Pretrained Checkpoints**
| name | pretrain | resolution |acc@1 | #params | model |
| :---: | :---: | :---: | :---: | :---: | :---: |
|`swin_tiny_224` |ImageNet-1K |224x224|81.2|28M|[github](https://github.com/rishigami/Swin-Transformer-TF/releases/download/v0.1-tf-swin-weights/swin_tiny_224.tgz)|
|`swin_small_224`|ImageNet-1K |224x224|83.2|50M|[github](https://github.com/rishigami/Swin-Transformer-TF/releases/download/v0.1-tf-swin-weights/swin_small_224.tgz)|
|`swin_base_224` |ImageNet-22K|224x224|85.2|88M|[github](https://github.com/rishigami/Swin-Transformer-TF/releases/download/v0.1-tf-swin-weights/swin_base_224.tgz)|
|`swin_base_384` |ImageNet-22K|384x384|86.4|88M|[github](https://github.com/rishigami/Swin-Transformer-TF/releases/download/v0.1-tf-swin-weights/swin_base_384.tgz)|
|`swin_large_224`|ImageNet-22K|224x224|86.3|197M|[github](https://github.com/rishigami/Swin-Transformer-TF/releases/download/v0.1-tf-swin-weights/swin_large_224.tgz)|
|`swin_large_384`|ImageNet-22K|384x384|87.3|197M|[github](https://github.com/rishigami/Swin-Transformer-TF/releases/download/v0.1-tf-swin-weights/swin_large_384.tgz)|
## Examples
Initializing the model:
```python
from swintransformer import SwinTransformer
model = SwinTransformer('swin_tiny_224', num_classes=1000, include_top=True, pretrained=False)
```
You can use a pretrained model like this:
```python
import tensorflow as tf
from swintransformer import SwinTransformer
model = tf.keras.Sequential([
tf.keras.layers.Lambda(lambda data: tf.keras.applications.imagenet_utils.preprocess_input(tf.cast(data, tf.float32), mode="torch"), input_shape=[*IMAGE_SIZE, 3]),
SwinTransformer('swin_tiny_224', include_top=False, pretrained=True),
tf.keras.layers.Dense(NUM_CLASSES, activation='softmax')
])
```
If you use a pretrained model with TPU on kaggle, specify `use_tpu` option:
```python
import tensorflow as tf
from swintransformer import SwinTransformer
model = tf.keras.Sequential([
tf.keras.layers.Lambda(lambda data: tf.keras.applications.imagenet_utils.preprocess_input(tf.cast(data, tf.float32), mode="torch"), input_shape=[*IMAGE_SIZE, 3]),
SwinTransformer('swin_tiny_224', include_top=False, pretrained=True, use_tpu=True),
tf.keras.layers.Dense(NUM_CLASSES, activation='softmax')
])
```
没有合适的资源?快使用搜索试试~ 我知道了~
Swin-T-使用Tensorflow实现的Swin-Transformer目标检测算法-附项目源码-优质项目实战.zip
共4个文件
py:2个
txt:1个
md:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 116 浏览量
2024-04-29
10:33:03
上传
评论
收藏 7KB ZIP 举报
温馨提示
Swin-T_使用Tensorflow实现的Swin-Transformer目标检测算法_附项目源码_优质项目实战
资源推荐
资源详情
资源评论
收起资源包目录
Swin-T_使用Tensorflow实现的Swin-Transformer目标检测算法_附项目源码_优质项目实战.zip (4个子文件)
Swin-T_使用Tensorflow实现的Swin-Transformer目标检测算法_附项目源码_优质项目实战
swintransformer
__init__.py 35B
model.py 19KB
requirements.txt 23B
README.md 3KB
共 4 条
- 1
资源评论
极智视界
- 粉丝: 2w+
- 资源: 1448
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功