MCPcopy Index your code
hub / github.com/Tete-Xiao/ReSim

github.com/Tete-Xiao/ReSim @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
82 symbols 177 edges 14 files 33 documented · 40%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ReSim

ReSim pipeline

This repository provides the PyTorch implementation of Region Similarity Representation Learning (ReSim) described in this paper:

@Article{xiao2021region,
  author  = {Tete Xiao and Colorado J Reed and Xiaolong Wang and Kurt Keutzer and Trevor Darrell},
  title   = {Region Similarity Representation Learning},
  journal = {arXiv preprint arXiv:2103.12902},
  year    = {2021},
}

tldr; ReSim maintains spatial relationships in the convolutional feature maps when performing instance contrastive pre-training, which is useful for region-related tasks such as object detection, segmentation, and dense pose estimation.

Installation

Assuming a conda environment:

conda create --name resim python=3.7
conda activate resim

# NOTE: if you are not using CUDA 10.2, you need to change the 10.2 in this command appropriately. 
# Code tested with torch 1.6 and 1.7
# (check CUDA version with e.g. `cat /usr/local/cuda/version.txt`)
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch

Pre-training

This codebase is based on the original MoCo codebase -- see this README for more details.

To pre-train for 200 epochs using the ReSim-FPN implementation as described in the paper:

python main_moco.py -a resnet50 --lr 0.03 --batch-size 256 \
       --dist-url tcp://localhost:10005 --multiprocessing-distributed --world-size 1 --rank 0 \
       --mlp --moco-t 0.2 --aug-plus --cos --epochs 200 \
       /location/of/imagenet/data/folder

ResNet-50 Pre-trained Models

Checkpoint Pre-train Epochs COCO AP @2x MoCo Checkpoint Detectron Backbone
ReSim-FPN 400 41.9 Download Download
ReSim-FPN 200 41.4 Download Download
ReSim-C4 200 41.1 Download Download

Detection

See these instructions for more details, but in brief:

# first install detectron2
# then place COCO-2017 dataset detection/datasets/coco

cd detection
python convert-pretrain-to-detectron2.py ../resim_fpn_checkpoint_latest.pth.tar detectron_resim_fpn_checkpoint_latest.pth.tar
python train_net.py --dist-url 'tcp://127.0.0.1:17654' --config-file configs/coco_R_50_FPN_2x_moco.yaml --num-gpus 8 MODEL.WEIGHTS detectron_resim_fpn_checkpoint_latest.pth.tar TEST.EVAL_PERIOD 180000 OUTPUT_DIR results/coco2x-resim-fpn SOLVER.CHECKPOINT_PERIOD 180000

License

This project is under the CC-BY-NC 4.0 license. See LICENSE.

Core symbols most depended-on inside this repo

update
called by 9
main_moco.py
_resnet
called by 9
moco/models.py
_make_layer
called by 4
moco/models.py
concat_all_gather
called by 4
moco/builder.py
accuracy
called by 3
main_moco.py
conv3x3
called by 3
moco/models.py
conv1x1
called by 3
moco/models.py
_batch_unshuffle_ddp
called by 3
moco/builder.py

Shape

Method 42
Function 25
Class 15

Languages

Python99%
C1%

Modules by API surface

moco/models.py24 symbols
main_moco.py16 symbols
moco/transforms.py9 symbols
moco/builder.py8 symbols
moco/loader.py6 symbols
detection/train_net.py6 symbols
moco/datasets.py4 symbols
lib/prroi_pool/prroi_pool.py4 symbols
lib/prroi_pool/functional.py4 symbols
lib/prroi_pool/src/prroi_pooling_gpu.c1 symbols

For agents

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

⬇ download graph artifact