Skip to content

Repository files navigation

OpenAL

OpenAL is an Active Learning (AL) framework for classification.

The AL is classified into two approaches by samples of unlabeled data. The AL that assumes the unlabeled data contains only in-distribution data is called Standard AL. If the unlabeled data includes not only in-distribution but also out-of-distribution, it is called Open-set AL. This framework covers Standard AL and Open-set AL. So, we named our framework OpenAL.

We hope that AL research can advance further through this framework.

Environments

We build environments based on the docker image nvcr.io/nvidia/pytorch:22.12-py3.

python==3.8.10
torch==1.14.0a0+410ce96
torchvision==0.15.0a0
accelerate==0.18.0
wandb
torchvision==0.15.0a0
omegaconf
timm==0.9.2
seaborn==0.12.2
torchlars==0.1.2
ftfy==6.1.3
open-clip-torch==2.24.0
finch-clust==0.1.9

Query Strategies

ALTypeMethodClass NamePaper
None-AL-Random SamplingRandomSampling-
Standard ALUncertaintyLeast ConfidenceLeastConfidenceIJCNN 2014 - paper
Standard ALUncertaintyMargin SamplingMarginSamplingIJCNN 2014 - paper
Standard ALUncertaintyEntropyEntropySamplingIJCNN 2014 - paper
Standard ALUncertaintyVarRatioVarRatioICMLW 2020 - paper
Standard ALUncertaintyMeanSTDMeanSTDCVPRW 2016 - paper
Standard ALUncertaintyLearning LossLearningLossALCVPR 2019 - paper, unofficial
Standard ALUncertaintyAlphaMixAlphaMixSamplingCVPR 2022 - paper, official
Standard ALUncertaintyBALDBALDarXiv 2011.12 - paper, unofficial
Standard ALHybridBADGEBADGENeurIPS 2019 - paper, official
Standard ALDiversityK-Center GreedyKCenterGreedyCVPR 2018 - paper, official
Standard ALDiversityK-Center Greedy + Class BalancedKCenterGreedyCBWACV 2022 - paper, official
Open-set ALContrastive LearningCCALCCALICCV 2021 - paper, official
Open-set ALContrastive LearningMQNetMQNetNeurIPS 2022 - paper, official
Open-set ALOOD DetectorLfOSALfOSACVPR 2022 - paper, official
Open-set ALOOD DetectorEOALEOALAAAI 2024 - paper, official
Open-set ALVLMCLIPNALCLIPNALarXiv 2024.8 - paper, official

CLIPN checkpoint

CLIPNAL uses a CLIPN checkpoint shared from CLIPN repository. The checkpoint can download in here.

Configuration for Experiments

All configuration files are in ./configs.
You can modify the config files to run your experiment settings.

./configs
├── default_setting.yaml
├── openset_al
│ ├── ccal.yaml
│ ├── clipnal.yaml
│ ├── eoal.yaml
│ ├── lfosa.yaml
│ └── mqnet.yaml
├── ssl
│ ├── csi.yaml
│ └── simclr.yaml
└── standard_al
├── badge.yaml
├── bald.yaml
├── entropy_sampling.yaml
├── featmix_sampling.yaml
├── kcenter_greedy_cb.yaml
├── kcenter_greedy.yaml
├── learning_loss.yaml
├── least_confidence.yaml
├── margin_sampling.yaml
├── meanstd_sampling.yaml
├── random_sampling.yaml
└── varratio_sampling.yaml

How to Use

  • You can use our framework in colab. This code is a tutorial on how to use the query strategy for Standard AL and the CLIPNAL method, which is one of the Open AL methods.

Standard AL

fromquery_strategiesimportcreate_query_strategymodel=# classifiertrainset=# training data set with labeled and unlabeled samplestransform=# transforms for extracting featuressampler_name=# SubsetRandomSampler or SubsetWeightedRandomSampleris_labeled=# bool type 1-d array (N,). N is the number of samples. True is labeled samples and False is unlabeled samples. n_query=# the number of samples for annotationn_subset=# sampling size for unlabeled databatch_size=# batch sizenum_workers=# number of workersstrategy=create_query_strategy(
strategy_name=# strategy name, model=model,
dataset=trainset, transform=transform,
sampler_name=sampler_name,
is_labeled=is_labeled, n_query=n_query, n_subset=n_subset,
batch_size=batch_size, num_workers=num_workers
)
# select query using the trained model on labeled samplesquery_idx=strategy.query(model)
strategy.update(query_idx=query_idx)

Open-set AL

fromquery_strategiesimportcreate_query_strategymodel=# classifiertrainset=# training data set with labeled and unlabeled samplestransform=# transforms for extracting featuressampler_name=# SubsetRandomSampler or SubsetWeightedRandomSampleris_labeled=# bool type 1-d array (N,). N is the number of samples. True is labeled ID samples and False is unlabeled samples. n_query=# the number of samples for annotationn_subset=# sampling size for unlabeled databatch_size=# batch sizenum_workers=# number of workers# select strategy openset_params= {
'is_openset' : # if unlabeled data contains OOD samples, True, or False'is_unlabeled' : # bool type 1-d array (N,). N is the number of samples. True is unlabeled samples and False is labeled ID and OOD samples.'is_ood' : # bool type 1-d array (N,). N is the number of samples. True is OOD samples and False is unlabeled and ID samples.'id_classes' : # ID class names'savedir' : # save directory'seed' : # seed
}
strategy=create_query_strategy(
strategy_name=# strategy name, model=model,
dataset=trainset, transform=transform,
sampler_name=sampler_name,
is_labeled=is_labeled, n_query=n_query, n_subset=n_subset,
batch_size=batch_size, num_workers=num_workers,
**openset_params
)
# select query using trained model on labeled samplesquery_idx=strategy.query(model)
id_query_idx=strategy.update(query_idx=query_idx)

How to Run

Supervised Learning with full train dataset

python main.py \
default_cfg=./configs/default_setting.yaml \
DATASET.name=$dataname \
DEFAULT.savedir=$savedir

Standard AL

python main.py \
default_cfg=./configs/default_setting.yaml \
strategy_cfg=./configs/standard_al/$strategy_name.yaml \
DATASET.name=$dataname \
AL.n_start=$n_start \
AL.n_query=$n_query \
AL.n_end=$n_end \
DEFAULT.savedir=$savedir

Open-set AL

python main.py \
default_cfg=./configs/default_setting.yaml \
openset_cfg=./configs/openset_al/$strategy_name.yaml \
DATASET.name=$dataname \
AL.ood_ratio=$ood_ratio \
AL.id_ratio=$id_ratio \
AL.n_start=$n_start \
AL.n_query=$n_query \
AL.n_end=$n_end \
DEFAULT.savedir=$savedir

About

No description, website, or topics provided.

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages