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

support transformer backbone #465

Merged
merged 24 commits into from
Apr 22, 2021
Merged

support transformer backbone #465

merged 24 commits into from
Apr 22, 2021

Conversation

xiexinch
Copy link
Collaborator

@xiexinch xiexinch commented Apr 9, 2021

Support transformer backbone.
This PR modified from https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_transformer.py.

  • Support load pretrained checkpoints from reference repo.
  • Training image size can be different from pretrain image.
  • Support dynamic test image size at evaluation.

Usage

Backbone config should be like this.

backbone=dict(
        type='VisionTransformer',
        img_size=(512, 512),
        patch_size=16,
        in_channels=3,
        embed_dim=768,
        depth=12,
        mlp_ratio=4,
        qkv_bias=True,
        qk_scale=None,
        representation_size=None,
        drop_rate=0.0,
        attn_drop_rate=0.0,
        norm_cfg=dict(type='LN'),
        act_cfg=dict(type='GELU'),
        norm_eval=False)

We can download checkpoints from https://github.com/rwightman/pytorch-image-models by setting pretrained

model = dict(
pretrained='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-vitjx/jx_vit_base_p16_224-80ecf9dd.pth',
backbone=dict(...))

@codecov
Copy link

codecov bot commented Apr 9, 2021

Codecov Report

❗ No coverage uploaded for pull request base (master@67eee62). Click here to learn what that means.
The diff coverage is 88.05%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #465   +/-   ##
=========================================
  Coverage          ?   86.53%           
=========================================
  Files             ?       98           
  Lines             ?     5133           
  Branches          ?      829           
=========================================
  Hits              ?     4442           
  Misses            ?      534           
  Partials          ?      157           
Flag Coverage Δ
unittests 86.53% <88.05%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmseg/models/backbones/vit.py 87.97% <87.97%> (ø)
mmseg/models/backbones/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67eee62...6827803. Read the comment docs.

@xvjiarui
Copy link
Collaborator

There are some unresolved comments.

@xvjiarui xvjiarui merged commit 5b33faa into open-mmlab:master Apr 22, 2021
@xiexinch xiexinch deleted the vit branch April 25, 2021 12:02
bowenroom pushed a commit to bowenroom/mmsegmentation that referenced this pull request Feb 25, 2022
* vit backbone

* fix lint

* add docstrings and fix pretrained pos_embed dim not match prob

* add unittest for vit

* fix lint

* add vit based fcn configs

* fix import error

* support multiple resolution input images

* upsample pos_embed at init_weights

* support resize pos_embed at evaluation

* fix training errors

* add more unitest code for vit backbone

* unitest for uncovered code

* add norm_eval unittest

* refactor _pos_embeding

* minor change

* change var name

* rafactor init_weight

* load weights after resize

* ignore 'module' in pretrain checkpoint

* add with_cp

* add with_cp

Co-authored-by: Jiarui XU <xvjiarui0826@gmail.com>
wjkim81 pushed a commit to wjkim81/mmsegmentation that referenced this pull request Dec 3, 2023
* update tutorials

* add 0_config.md
sibozhang pushed a commit to sibozhang/mmsegmentation that referenced this pull request Mar 22, 2024
* a little bit faster confusion matrix

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

Successfully merging this pull request may close these issues.

2 participants