This is a PyTorch implementation of the JointCrop paper (AAAI 2025). The code is mainly modified from MoCo v3.
Due to AAAI's page limit, we have supplemented the appendix of JointCrop within the code repository.
- Prepare the environment.
Creating a python environment and activate it via the following command.
conda create -n jointcrop python=3.9
conda activate jointcrop
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia
pip install tensorboard timm==0.4.9 numpy==1.26.4
- Clone this repository.
git clone https://github.com/btzyd/JointCrop.git
- Prepare the dataset ImageNet.
Download and organize the ImageNet-1K dataset according to the same form as MoCo v3.
MoCo v3 based on ResNet50 requires 2 nodes with a total of 16 GPUs and about 29GB of memory per GPU.
On the first node, run:
python main_jointcrop.py \
--moco-m-cos --crop-min=.2 \
--dist-url 'tcp://[your first node address]:[specified port]' \
--multiprocessing-distributed --world-size 2 --rank 0 \
--ckpt_path './checkpoint_resnet50_ep100_jointcrop0' \
[your imagenet-folder with train and val folders]
On the second node, run the same command with --rank 1.
For scripts with 300 epochs, you can refer to the MoCo v3 repository.
The fine-tuning of MoCo v3 based on ResNet50 nearly requires a total of 8 GPUs on 1 node, with about 6GB memory per GPU.
python main_lincls.py \
--dist-url 'tcp://127.0.0.1:10001' \
--multiprocessing-distributed --world-size 1 --rank 0 \
--pretrained 'checkpoint_resnet50_ep100_jointcrop0/checkpoint_0099.pth.tar' \
[your imagenet-folder with train and val folders]
epoch | MoCo v3 baseline |
MoCo v3 + JointCrop(0) |
---|---|---|
100 | 68.9 | 69.47 |
300 | 72.8 | 73.23 |
To be added after publication.