Skip to content

Active Learning Base Class

all active learning methods are inherited from ActiveLearning class. Only initialize methods are different. It means that you can use any active learning method by calling sample method of ActiveLearning class.

sample(image_dir, num_images, result_dir, save_images=True, hold=True)

Sample images from the image directory

Parameters:

Name Type Description Default
sampled_image_dir Union[Path, str]

image directory

required
num_images int

number of images to sample

required
result_dir Union[Path, str]

result directory

required
save_images bool

save sampled images. Defaults to True.

True
hold bool

hold process. Defaults to True.

True

Returns:

Name Type Description
str str

result directory

RandomSampling

Bases: ActiveLearning

__init__(seed=0)

EntropySampling

Bases: ActiveLearning

__init__(hub, image_size=None, letter_box=None, batch_size=32, num_workers=4, device='0')

Entropty Sampling

Parameters:

Name Type Description Default
hub Hub

Hub

required
image_size int

Image size. Defaults to None.

None
letter_box bool

Letter box. Defaults to None.

None
batch_size int

Batch size. Defaults to 32.

32
num_workers int

Number of workers. Defaults to 4.

4
device str

Device. Defaults to "0".

'0'

PL2NSampling

Bases: ActiveLearning

__init__(hub, diversity_sampling=False, image_size=None, letter_box=None, batch_size=32, num_workers=4, device='0')

PL2N Sampling

Parameters:

Name Type Description Default
hub Hub

Hub

required
diversity_sampling bool

Diversity sampling. Defaults to False.

False
image_size int

Image size. Defaults to None.

None
letter_box bool

Letter box. Defaults to None.

None
batch_size int

Batch size. Defaults to 32.

32
num_workers int

Number of workers. Defaults to 4.

4
device str

Device. Defaults to "0".

'0'