brails.processors.garage_detector.garage_detector module
Class object to use and retrain the garage detector model.
- class brails.processors.garage_detector.garage_detector.GarageDetector(input_data: dict | None = None)
Bases:
object
A class to manage and configure the system for detecting garages.
This class provides an organized structure to store system parameters and configurations required for training and inference tasks in a garage detection system. It initializes a nested dictionary to hold various configurations and parameters for different stages of processing.
- Attributes_
system_dict (Dict[str, Dict[str, Any]]): A dictionary to store system configurations and parameters, initialized with nested dictionaries for training and inference settings.
- Methods_
- __init__(self, input_data: Optional[Dict[str, Any]] = None):
Initializes the GarageDetector instance with default configurations and optionally with provided input data.
- set_fixed_params(self):
Configures fixed parameters required for the garage detection system.
- train(self, comp_coeff: int = 3, top_only: bool = False,
optim: str = “adamw”, lr: float = 1e-4, nepochs: int = 25, ngpu: int = 1) -> None:
Sets up parameters for training the garage detection model.
- predict(images: ImageSet, model_path: str = 'tmp/models/efficientdet-d4_garageDetector.pth') dict
Predict the existence of garages in buildings from the given images.
- Args__
- images (ImageSet): ImageSet object containing the collection of
images to be analyzed.
- modelPath (str): The file path to the pre-trained model. If the
default path is used, the model will be downloaded (default is ‘tmp/models/efficientdet-d4_garageDetector.pth’).
- Returns__
- predictions (dict): Existence of garages with the keys
being the same keys used in ImageSet.images.
This method processes the images provided, loads the specified model, and performs inference to determine the existence of garages in each building. It handles the setup of the inference environment, manages model loading, and provides a report on the execution time.
It also includes functions for polygon creation, intersection checks, and managing thresholds during inference to ensure accurate predictions.
The results of the predictions are also stored in the instance’s system dictionary under the key ‘predictions’.
- retrain(optim: str = 'adamw', learning_rate: float = 0.0001, nepochs: int = 25, ngpu: int = 1) None
Retrain the garage detection model with specified parameters.
- Args__
optim (str): Optimizer to use for training (default is “adamw”). lr (float): The learning rate for the optimizer (default is 1e-4). nepochs (int): Number of epochs to train the model (default is 25). ngpu (int): The number of GPUs to use for training (default is 1).
This method configures the training parameters, sets the training and validation datasets, initializes the model architecture, and starts the re-training process for the default garage detector in BRAILS++.
- train(comp_coeff: int = 3, top_only: bool = False, optim: str = 'adamw', learning_rate: float = 0.0001, nepochs: int = 25, ngpu: int = 1) None
Train a garage detection model.
- Args__
comp_coeff (int): Coefficient for comparison, default is 3. top_only (bool): If True, only the top layers are trained, default
is False.
optim (str): Optimizer type, default is “adamw”. lr (float): Learning rate, default is 1e-4. nepochs (int): Number of epochs for training, default is 25. ngpu (int): Number of GPUs to use, default is 1.
- Updates__
self.system_dict (Dict[str, Dict[str, Any]]): Updates the model configuration parameters for training in the system dictionary.