MCPcopy Index your code
hub / github.com/LiheYoung/MiningFSS

github.com/LiheYoung/MiningFSS @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
41 symbols 118 edges 6 files 3 documented · 7%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Mining Latent Classes for Few-shot Segmentation

Lihe Yang, Wei Zhuo, Lei Qi, Yinghuan Shi, Yang Gao.

This codebase contains baseline of our paper Mining Latent Classes for Few-shot Segmentation, ICCV 2021 Oral.

Several key modifications to the simple yet effective metric learning framework: - Remove the final residual stage in ResNet for stronger generalization - Remove the final ReLU for feature matching - Freeze all the BatchNorms from ImageNet pretrained model

Environment

This codebase was tested with the following environment configurations.

  • Ubuntu 18.04
  • CUDA 11.2
  • Python 3.7.4
  • PyTorch 1.6.0
  • Pillow, numpy, torchvision, tqdm
  • Two NVIDIA V100 GPUs

Getting Started

Data Preparation

Pretrained model: ResNet-50 | ResNet-101

Dataset: Pascal JPEGImages | SegmentationClass | ImageSets

File Organization

├── ./pretrained
    ├── resnet50.pth
    └── resnet101.pth

├── [Your Pascal Path]
    ├── JPEGImages
    │   ├── 2007_000032.jpg
    │   └── ...
    │
    ├── SegmentationClass
    │   ├── 2007_000032.png
    │   └── ...
    │
    └── ImageSets
        ├── train.txt
        └── val.txt

Run the Code

CUDA_VISIBLE_DEVICES=0,1 python -W ignore main.py \
  --dataset pascal --data-root [Your Pascal Path] \
  --backbone resnet50 --fold 0 --shot 1

You may change the backbone from resnet50 to resnet101, change the fold from 0 to 1/2/3, or change the shot from 1 to 5 for other settings.

Performance and Trained Models

Here we report the performance of our modified baseline on Pascal. You can click on the numbers to download corresponding trained models.

The training time is measured on two V100 GPUs. Compared with other works, our method is efficient to train.

Setting Backbone Training time / fold Fold 0 Fold 1 Fold 2 Fold 3 Mean
1-shot ResNet-50 40 minutes 54.9 66.5 61.7 48.3 57.9
1-shot ResNet-101 1.1 hours 57.2 68.5 61.3 53.3 60.1
5-shot ResNet-50 2.3 hours 61.6 70.3 70.5 56.4 64.7
5-shot ResNet-101 3.5 hours 64.2 74.0 71.5 61.3 67.8

Acknowledgement

We thank PANet, PPNet, PFENet and other FSS works for their great contributions.

Citation

If you find this project useful for your research, please consider citing:

@inproceedings{yang2021mining,
  title={Mining Latent Classes for Few-shot Segmentation},
  author={Yang, Lihe and Zhuo, Wei and Qi, Lei and Shi, Yinghuan and Gao, Yang},
  booktitle={ICCV},
  year={2021}
}

Core symbols most depended-on inside this repo

conv3x3
called by 6
model/resnet.py
_resnet
called by 5
model/resnet.py
conv1x1
called by 3
model/resnet.py
_make_layer
called by 3
model/resnet.py
set_seed
called by 3
util/utils.py
evaluate
called by 2
main.py
crop
called by 2
dataset/transform.py
hflip
called by 2
dataset/transform.py

Shape

Method 19
Function 16
Class 6

Languages

Python100%

Modules by API surface

model/resnet.py18 symbols
util/utils.py7 symbols
dataset/fewshot.py6 symbols
model/matching.py4 symbols
main.py3 symbols
dataset/transform.py3 symbols

For agents

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

⬇ download graph artifact