MCPcopy Index your code
hub / github.com/alinlab/SelfPatch

github.com/alinlab/SelfPatch @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
467 symbols 1,376 edges 62 files 137 documented · 29%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Patch-level Representation Learning for Self-supervised Vision Transformers (SelfPatch)

PyTorch implementation for "Patch-level Representation Learning for Self-supervised Vision Transformers" (accepted Oral presentation in CVPR 2022)

thumbnail

Requirements

  • torch==1.7.0
  • torchvision==0.8.1

Pretraining on ImageNet

python -m torch.distributed.launch --nproc_per_node=8 main_selfpatch.py --arch vit_small --data_path /path/to/imagenet/train --output_dir /path/to/saving_dir --local_crops_number 8 --patch_size 16 --batch_size_per_gpu 128 --out_dim_selfpatch 4096 --k_num 4

Pretrained weights on ImageNet

You can download the weights of the pretrained models on ImageNet. All models are trained on ViT-S/16. For detection and segmentation downstream tasks, please check SelfPatch/detection, SelfPatch/segmentation.

backbone arch checkpoint
DINO ViT-S/16 download (pretrained model from VISSL)
DINO + SelfPatch ViT-S/16 download

Evaluating video object segmentation on the DAVIS 2017 dataset

Step 1. Prepare DAVIS 2017 data

cd $HOME
git clone https://github.com/davisvideochallenge/davis-2017
cd davis-2017
./data/get_davis.sh

Step 2. Run Video object segmentation

python eval_video_segmentation.py --data_path /path/to/davis-2017/DAVIS/ --output_dir /path/to/saving_dir --pretrained_weights /path/to/model_dir --arch vit_small --patch_size 16

Step 3. Evaluate the obtained segmentation

git clone https://github.com/davisvideochallenge/davis2017-evaluation 
$HOME/davis2017-evaluation
python /path/to/davis2017-evaluation/evaluation_method.py --task semi-supervised --davis_path /path/to/davis-2017/DAVIS --results_path /path/to/saving_dir

Video object segmentation examples on the DAVIS 2017 dataset

Video (left), DINO (middle) and our SelfPatch (right)

img

Acknowledgement

Our code base is built partly upon the packages: DINO, mmdetection, mmsegmentation and XCiT

Citation

If you use this code for your research, please cite our papers.

@InProceedings{Yun_2022_CVPR,
    author    = {Yun, Sukmin and Lee, Hankook and Kim, Jaehyung and Shin, Jinwoo},
    title     = {Patch-Level Representation Learning for Self-Supervised Vision Transformers},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2022},
    pages     = {8354-8363}
}

Core symbols most depended-on inside this repo

print
called by 80
utils.py
update
called by 10
utils.py
trunc_normal_
called by 7
utils.py
norm1
called by 7
segmentation/backbones/hrnet.py
max
called by 6
utils.py
norm2
called by 6
segmentation/backbones/hrnet.py
forward_plugin
called by 6
segmentation/backbones/resnet.py
apply
called by 5
utils.py

Shape

Method 254
Function 132
Class 81

Languages

Python100%

Modules by API surface

utils.py61 symbols
selfpatch_vision_transformer.py47 symbols
segmentation/backbones/resnet.py28 symbols
detection/backbone/vit_SelfPatch.py25 symbols
segmentation/backbones/swin.py23 symbols
segmentation/backbones/bisenetv2.py21 symbols
segmentation/backbones/hrnet.py17 symbols
segmentation/tools/deploy_test.py16 symbols
segmentation/backbones/resnest.py15 symbols
segmentation/backbones/cgnet.py15 symbols
segmentation/backbones/bisenetv1.py15 symbols
main_selfpatch.py15 symbols

For agents

$ claude mcp add SelfPatch \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact