Coder Social home page Coder Social logo

pop's Introduction

POP for Generalized Few-shot Semantic Segmentation

This repository is for the CVPR2023 paper "Learning Orthogonal Prototypes for Generalized Few-shot Semantic Segmentation".

Requirements

The code is verified with Python 3.6 and PyTorch 1.8. It also relies on NumPy and OpenCV.

Datasets

Please refer to PFENet to get PASCAL VOC with SBD and COCO 2014. The ground truth images for COCO 2014 can be generated using utils/coco_parse_script.py. Data paths should be as follows:

.{YOUR_PASCAL_PATH}
├── JPEGImages
├── SegmentationClassAug

.{YOUR_COCO_PATH}
├── train2014
├── train_no_crowd
├── val2014
├── val_no_crowd

After the first stage training, the code will save the filenames for each class as txt files in dataset/list/. Then, you can use utils/gen_fs_list.py to select few-shot data for the second stage training with different random seeds.

Pretrained Models

Download ImageNet pretrained ResNet-50 here. Check models to get pretrained POP models.

Usage

Training

POP performs two-stage training for generalized few-shot semantic segmentation.

Stage 1: Base Class Learning

We use 1 GPU to train a base model on PASCAL-5i and 4 GPUs on COCO-20i. Run the training code with scripts/train_coco_fold0_base_q.sh and scripts/train_voc_fold0_base.sh. You should modify the arguments according to your settings. Note that you should specify YOUR_RESTORE_PATH as the path to ImageNet-pretrained ResNet-50 models.

Stage 2: Novel Class Updating

Run the training code with scripts/ft_coco.sh and scripts/ft_voc.sh with modified arguments according to your settings. While ft_pop.py also supports larger batch size with multi-gpu training, we find small batch size often works better. Note that you should specify YOUR_RESTORE_PATH as the path to the base models trained in Stage 1. You can also finetune them on different support data by setting multiple random seeds.

FP16 Training

To additionally speed up the training process, we support mix precision training in train_base.py and ft_pop.py, which can significantly reduce the time cost. To enable it, you can add --fp16 in the training scripts.

Testing

Use scripts/evaluate_coco_fold0.sh and scripts/evaluate_voc_fold0.sh to perform GFSS evaluation on the two datasets.

References

This repo is mainly built based on PFENet and GFS-Seg. Thanks for their great work!

Citation

If you find our code useful, please consider to cite with:

@inproceedings{liu2023learning,
  title={Learning Orthogonal Prototypes for Generalized Few-shot Semantic Segmentation},
  author={Liu, Sun-Ao and Zhang, Yiheng and Qiu, Zhaofan and Xie, Hongtao and Zhang, Yongdong and Yao, Ting},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year={2023}
}

pop's People

Contributors

lsa1997 avatar

Stargazers

CHC avatar  avatar  avatar Lujian_Yao avatar  avatar  avatar WangHr avatar DonghuiLi avatar  avatar  avatar Paolo Manchisi avatar Tangchen avatar 黎健钊 avatar JiangLulu avatar  avatar JieLiu avatar  avatar  avatar Wang Changqi avatar Joe Nevaeh avatar

Watchers

Kostas Georgiou avatar  avatar

pop's Issues

Some problems during training

Hi! Thank you for your great work.
When I tried to replicate your work, I encountered the following problem.


Traceback (most recent call last):
File "train_base.py", line 320, in
main()
File "train_base.py", line 291, in main
logger.info('>>>>>>> ------------------- <<<<<<<')
File "/home2/hkz/nips24/POP-main/engine.py", line 137, in exit
torch.cuda.empty_cache()
File "/home/hkz/miniconda3/envs/pop2/lib/python3.6/site-packages/torch/cuda/memory.py", line 114, in empty_cache
torch._C._cuda_emptyCache()
RuntimeError: CUDA error: device-side assert triggered


Have you encountered similar problems in the course of training? If it's convenient, please let me know which GPU you're using. Thank you !!!
Uploading 问题pop.jpg…

What is the improper setting ?

As mentioned in your model readme file, "Note that all models are trained based on the released code. We fix an improper setting in the cropping operation and achieve results better than those reported in our paper." I would like to know what is the improper setting and how to fix it.

Thanks

base dataset python file is missing

Hi! Thank you for your great work.

In the "dataset folder/voc.py", It loads the "BaseDataset" class from the "dataset_folder/base_dataset.py".
However, from the github, base_dataset.py does not exist.
Can you share its code?

Also, Can you upload the base training code for COCO along with the dataset loading part?

Thank you.

Couldn't find the pre-trained ResNet

Hi, Thank you very much for your amazing work.
I would love to use your model.

I think that there is some kind of permit issue when downloading the pre trained ResNet.
When I click on the link, this is the screen that I get:

image

I tried to go to the PFENet repository and download from there, but the link was removed. The link provided in the closed issue was also removed.

Would it be possible for you to provide the pre trained ResNet again?

Thank you very much in advance,
\Luiza

Missing file './dataset/list/voc/fold0/fold0_1shot_seed123.txt' when restating the training

Hi, thank you again for your very nice work.

I am getting an error when using this repository, which I would be very grateful if you could help me understand.

When I stop the training and try to start from the last saved model, I get into the issue that the code attempts to read the file "'./dataset/list/voc/fold0/fold0_1shot_seed123.txt'". However, this file was not generated.

I was trying to understand the code, and I think that this file should be created by 'gen_list' in 'gen_fs_list.py,' but this function is never called when using 'train_voc_fold0_base.sh' for training (at least not when interrupting the training before the maximum epochs).

Could you please help me solve this problem?

Thank you very much in advance,
\Luiza

Some problems during training

Hi! Thank you for your great work.
When I tried to replicate your work, I encountered the following problem.


Traceback (most recent call last):
File "train_base.py", line 320, in
main()
File "train_base.py", line 291, in main
logger.info('>>>>>>> ------------------- <<<<<<<')
File "/home2/hkz/nips24/POP-main/engine.py", line 137, in exit
torch.cuda.empty_cache()
File "/home/hkz/miniconda3/envs/pop2/lib/python3.6/site-packages/torch/cuda/memory.py", line 114, in empty_cache
torch._C._cuda_emptyCache()
RuntimeError: CUDA error: device-side assert triggered


Have you encountered similar problems in the course of training? If it's convenient, please let me know which GPU you're using. Thank you !!!
pop

about pretained models

Hi! Thank you for your great work.
I cann't download ImageNet pretained ResNet-50 from PFENet using the link
Can you provide the download address
Thank you

resnet50

Hello, the ResNet50 network you are using returns a list, while using ResNet50V2 returns a tensor. However, if not properly processed, it defaults to using the network output from ResNet50V2, and an error will occur if ResNet50 is used. Also, your backbone was not frozen during training, right?
Also, I can't open the link you provided to get the pretrained ResNet50 model. Do you have any other solutions?

License

Thanks for your work!
Would you be able to add a license to your project?
Ideally MIT or Apache

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.