brails.processors.year_built_classifier.lib.datasets module

Class object that prepares data for the year built classifier.

class brails.processors.year_built_classifier.lib.datasets.YearBuiltFolder(image_folder, soft_labels=False, gaussian_std=1.5, transforms=None, classes=None, calc_perf=False)

Bases: Dataset

A PyTorch Dataset class for loading and preprocessing images.

img_paths

List of image file paths.

Type:

list[str]

filenames

List of image file names.

Type:

list[str]

labels

List of labels corresponding to images.

Type:

Union[list[str], list[np.ndarray]]

calc_perf

Whether to calculate performance metrics.

Type:

bool

soft_labels

Whether soft labels are assigned.

Type:

bool

classes

Array of unique class labels.

Type:

np.ndarray

class_weights

Weights for each class based on their frequencies.

Type:

dict[str, float]

train_weights

Weights for individual samples for training.

Type:

list[float]

transforms

Image transformations applied during loading.

Type:

Any

__len__()

Returns the total number of samples in the dataset.

__getitem__(index

int) -> tuple[torch.Tensor,torch.Tensor|list],str]: Returns the image, label, and image path for the given index.

loader(path

str) -> Image.Image: Loads and returns an image from the specified path.

loader(path)

Load an image from the specified path and converts it to RGB format.

Parameters:

path (str) – The file path of the image to load.

Returns:

The loaded image in RGB format.

Return type:

Image.Image