brails.processors.foundation_classifier.foundation_classifier module

Class object to predict if a building is elevated.

class brails.processors.foundation_classifier.foundation_classifier.FoundationElevationClassifier(input_data=None)

Bases: object

Classifier for predicting if a building is elevated.

This class utilizes a pretrained ResNet50 model for binary classification of images. It can preprocess images, apply optional building segmentation masks, and perform predictions.

checkpoint

Path to the model checkpoint. Defaults to the best pretrained model if not provided.

Type:

str

mask_buildings

Whether to apply building segmentation masks to input images.

Type:

bool

load_masks

Whether to use pre-generated segmentation masks.

Type:

bool

work_dir

Directory for storing intermediate files and results.

Type:

str

print_res

Whether to print prediction results during inference.

Type:

bool

classes

List of class labels (‘Non-elevated’, ‘Elevated’).

Type:

list[str]

checkpoints_dir

Directory for storing model checkpoints.

Type:

str

model_file

Path to the loaded or downloaded model checkpoint.

Type:

str

model_dir

Directory for segmentation model components.

Type:

str

device

Device to run computations (‘cuda’ or ‘cpu’).

Type:

str

test_transforms

Image transformations pipeline for preprocessing.

Type:

transforms.Compose

predict(images

ImageSet) -> dict: Predicts whether buildings in the given set of images are elevated or non-elevated. Returns a dictionary mapping image IDs to their predicted classes.

predict(images)

Predict whether a building is elevated from street-level imagery.

Parameters:

images (ImageSet) – An ImageSet object containing image file paths and their metadata.

Returns:

A dictionary mapping image IDs to predicted classes. The keys are derived from the ImageSet metadata, and the values are the predicted class labels (e.g., ‘elevated’, ‘non-elevated’).

Return type:

dict

Raises:

NotADirectoryError – If the directory specified in images.dir_path does not exist.

Notes

  • The model performs binary classification for each input image.

  • Class predictions and confidence scores are displayed if self.print_res is set to True.

  • Ensure the ImageSet object provides valid image paths and metadata.