brails.processors.ffh_predictor_klepac.ffh_predictor_klepac module
This module defines a class for retrieving tunnel data from NTI.
|
Predict Building First Floor Heights from images using a Detectron2 model. |
- class brails.processors.ffh_predictor_klepac.ffh_predictor_klepac.FFHPredictorKlepac(input_data: dict | None = None)
Bases:
object
Predict Building First Floor Heights from images using a Detectron2 model.
FFHPredictorKlepac automates the process of detecting key building components (houses and doors) in an image and estimates the first floor elevation based on their relative positions. It supports both default and user-specified models, preprocesses input images, and allows batch predictions over a collection of images.
Main Features: - Automatically downloads and caches a default model if none is provided. - Crops and resizes input images for optimal model performance. - Detects houses and doors to estimate FFH using geometric heuristics. - Provides batch prediction over a user-supplied image collection.
- Args:
- input_data (Optional[dict]):
Optional dictionary with initialization parameters. Supported key:
‘modelPath’: Path to a user-provided Detectron2 model file.
- Example:
>>> predictor = FFHPredictorKlepac( input_data={'modelPath': 'path/to/custom_model.pkl'} ) >>> results = predictor.predict(image_set)
- predict(images: ImageSet) Dict[str, float | None]
Perform first floor elevation predictions on a set of images.
This method loads a pre-trained model from self.model_path and uses it to predict the first floor height (FFH) for each image in the provided images collection. The images are preprocessed before inference, and the FFH is calculated from model outputs.
- Args:
- images (ImageSet):
- An ImageSet object with the following attributes:
dir_path (str): Path to the directory containing image files.
images (Dict[str, Any]): Dictionary mapping image keys to objects with a filename attribute (e.g., image filename string).
Returns: Dict[str, Optional[float]]
A dictionary mapping each image key to its predicted first floor height (float), or None if prediction was not possible (e.g., image file missing).
Raises: NotADirectoryError
If images.dir_path is not a valid directory path.