brails.processors.occupancy_classifier.occupancy_classifier module

Class object to use and retrain the occupancy classifier model.

class brails.processors.occupancy_classifier.occupancy_classifier.OccupancyClassifier(input_data=None)

Bases: ImageClassifier

Class for predicting building occupancy types from street-level imagery.

The OccupancyClassifier classifier attempts to predict occupancy types of buildings as 1 of 2 types: Residential or Other. The classification is done by the ImageClassifier class. This class is a wrapper that just sets up the inputs for that class.

Variables
model_path (str):

Path to the model file

predict(ImageSet)

To return the predictions for the set of images provided

predict(images)

Predict building occupancy type.

Parameters:

images (ImageSet) – ImageSet containing the set of images for which a prediction is required

Returns:

Dictionary with keys set to image names in ImageSet.images and values set to the predicted occupancy types

Return type:

dict

retrain(data_dir, batch_size=8, nepochs=100, plot_loss=True)

Retrain the current occupancy model using new data.

Parameters:
  • data_dir (str) – Path to the directory containing the new training data. The directory should be structured with subdirectories for each class, each containing the respective images.

  • batch_size (int, optional, default=8) – The number of samples per batch used during training.

  • nepochs (int, optional, default=100) – The number of epochs for which the model will be retrained.

  • plot_loss (bool, optional, default=True) – If True, displays a plot of the training loss over epochs.

Notes:

  • This method uses an instance of ImageClassifier to perform the

    retraining.

  • The current model is loaded from self.modelPath and updated with

    the new data.

  • Ensure data_dir is properly prepared and contains sufficient data

    for effective retraining.

Example:

retrainer = OccupancyClassifier({‘modelPath’:’path/to/current/model’}) retrainer.retrain(data_dir=”path/to/new/data”,

batch_size=16, nepochs=50, plot_loss=True)