Class-incremental learning (CIL) with Exemplar Super-COmpression and Regeneration based on prompTs (ESCORT), a diffusion-based approach that boosts CIL performance by storing exemplars with increased quantity and enhanced diversity under limited memory budget. ESCORT works by
- extracting visual and textual prompts from selected images and saving prompts instead of images
- regenerating exemplars from prompts with ControlNet for CIL model training in subsequent phases
Official implementation of
Prompt-Based Exemplar Super-Compression and Regeneration for Class-Incremental Learning
Ruxiao Duan1,
Yaoyao Liu1,
Jieneng Chen1,
Adam Kortylewski2,3,
Alan Yuille1,
1Johns Hopkins University,
2University of Freiburg,
3Max Planck Institute for Informatics
git clone https://github.com/lllyasviel/ControlNet.git
conda env create -f ControlNet/environment.yaml
conda activate control
- Download ControlNet from HuggingFace and save the Canny edge model (
control_sd15_canny.pth
) inControlNet/models/control_sd15_canny.pth
.
- Choose an image classification dataset and save all images in the form of
<data-dir>/<dataset-name>/<mode>/<class-label>/<image-filename>
<data-dir>
: directory to store all datasets.<dataset-name>
: name of the dataset.<mode>
: either "train" or "test".<class-label>
: the class tag, e.g., "cupcakes".<image-filename>
: the image filename, e.g., "0001.jpg".
- If the dataset is not implemented, add it to the scripts.
- In
utils/data.py
, set another class by specifying the dataset name and its number of categories. - In
utils/data_manager.py
, add a mapping from the dataset name to its class instance in_get_idata()
.
- In
- In
compress/compress.py
andcompress/compress_lowres.py
, setCNET_DIR
to<pwd>/ControlNet
. - In
compress/compress.py
andcompress/compress_lowres.py
, setDATA_DIR
to<data-dir>
. - In
utils/data.py
, setself.data_dir
to<data-dir>
. - In
utils/toolkit.py
, set return ofoutput_folder()
as path to the output folder.
-
We compress all the training images into edge maps and generate their copies by ControlNet in advance.
-
In
compress/compress.py
andcompress/compress_lowres.py
, setSEEDS
to seeds of your choice, e.g.,range(5)
. -
If the images are relatively high-resolution, run
python compress/compress.py
- If the images are relatively low-resolution, run
python compress/compress_lowres.py
- In
exps/config.json
set training parameters. Most configurations follow the convention of PyCIL, except:augmentation_prob
: the probability of replacing a real image during one of its generated copies during training.augmentations_per_image
: the number of generated copies per image.memory_per_class
: memory budget in units per class.real_per_class
: number of real exemplars per class.syn_per_class
: number of synthetic exemplars per class.
- For instance, if we can set
memory_per_class=20
,real_per_class=18
, andsyn_per_class=48
.
python main.py
The CIL framework is developed based on PyCIL.