Official implementation of Glocal Energy-based Learning for Few Shot Open-Set Recognition
(accepted by CVPR 2023).
This repo is tested with Python 3.10, Pytorch 1.13, CUDA 11.6. More recent versions of Python and Pytorch with compatible CUDA versions should also support the code.
Dataset Source can be downloaded here.
Download them and move datasets under data
folder.
Download pretrain weights here and move them under initialization
folder.
Just run main.py
for training and testing
For example, to train and test the 5-way 1-shot/5-shot setting on MiniImageNet:
python main.py --gpu 0 --max_epoch 100 --attention --energy --energy_loss --open_loss --lr 0.0001 --energy_method sum --pixel_wise --distance pixel_sim --pixel_conv --init_weights [/path/to/pretrained/weights] --dataset MiniImageNet --shot [number of shots] --ahead_combine --top_k [number of k]
to train and test the 5-way 1-shot/5-shot setting on TieredImageNet:
python main.py --gpu 0 --max_epoch 200 --attention --energy --energy_loss --open_loss --lr 0.0002 --energy_method sum --pixel_wise --distance pixel_sim --pixel_conv --init_weights [/path/to/pretrained/weights] --dataset TieredImageNet --shot [number of shots] --ahead_combine --top_k [number of k]
to train and test the 5-way 1-shot/5-shot setting on CIFAR-FS:
python main.py --gpu 0 --max_epoch 100 --attention --energy --energy_loss --open_loss --lr 0.0001 --energy_method sum --pixel_wise --distance pixel_sim --pixel_conv --init_weights [/path/to/pretrained/weights] --dataset CIFAR-FS --shot [number of shots] --ahead_combine --top_k [number of k]
to train and test the 5-way 1-shot/5-shot setting on CIFAR-FS without pixel branch:
python main.py --gpu 0 --max_epoch 100 --attention --energy --energy_loss --open_loss --lr 0.0001 --energy_method sum --init_weights [/path/to/pretrained/weights] --dataset CIFAR-FS --shot [number of shots]
@article{wang2023glocal,
title={Glocal Energy-based Learning for Few Shot Open-Set Recognition},
author={Haoyu Wang and Guansong Pang and Peng Wang and Lei Zhang and Wei Wei and Yanning Zhang},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
year={2023}
}
Part of the code is modified from FEAT, SnaTCHer, TANE and RFDNet.