deepness.processing.models.regressor.Regressor¶
- class Regressor(model_file_path: str)¶
Bases:
ModelBaseClass implements regression model.
Regression model is used to predict metric per pixel of the image.
Methods
Check if the model has correct output layers
Get channel name by id if exists in model metadata
Returns display name of the model class
Get detector type from metadata if exists
Get shape of the input for the model
Get number of input pixels in x and y direction (the same value)
Get detection confidence from metadata if exists
Get detection iou threshold from metadata if exists
Get model type from metadata
Get regression output scaling from metadata if exists
Get resolution from metadata if exists
Get segmentation small segment from metadata if exists
Get segmentation threshold from metadata if exists
Get standardization parameters from metadata if exists
Get tile size from metadata if exists
Get tiles overlap from metadata if exists
Get batch size of the model
Get model type from metadata
Returns number of channels in the input layer
Returns number of channels in the output layer
Get shapes of the outputs for the model
Get class names from metadata
Postprocess the model output.
Preprocess the batch of images for the model (resize, normalization, etc)
Process a single tile image
- check_loaded_model_outputs()¶
Check if the model has correct output layers
Correct means that: - there is at least one output layer - batch size is 1 or parameter - each output layer regresses only one channel - output resolution is square
- get_channel_name(layer_id: int, channel_id: int) str¶
Get channel name by id if exists in model metadata
- Parameters:
channel_id (int) – Channel id (means index in the output tensor)
- Returns:
Channel name or empty string if not found
- Return type:
str
- classmethod get_class_display_name() str¶
Returns display name of the model class
- Returns:
Display name of the model class
- Return type:
str
- get_detector_type() str | None¶
Get detector type from metadata if exists
Returns string value of DetectorType enum or None if not found¶
- Optional[str]
Detector type or None if not found
- get_input_shape() tuple¶
Get shape of the input for the model
- Returns:
Shape of the input (batch_size, channels, height, width)
- Return type:
tuple
- get_input_size_in_pixels() int¶
Get number of input pixels in x and y direction (the same value)
- Returns:
Number of pixels in x and y direction
- Return type:
int
- get_metadata_detection_confidence() float | None¶
Get detection confidence from metadata if exists
- Returns:
Detection confidence or None if not found
- Return type:
Optional[float]
- get_metadata_detection_iou_threshold() float | None¶
Get detection iou threshold from metadata if exists
- Returns:
Detection iou threshold or None if not found
- Return type:
Optional[float]
- get_metadata_model_type() str | None¶
Get model type from metadata
- Returns:
Model type or None if not found
- Return type:
Optional[str]
- get_metadata_regression_output_scaling() float | None¶
Get regression output scaling from metadata if exists
- Returns:
Regression output scaling or None if not found
- Return type:
Optional[float]
- get_metadata_resolution() float | None¶
Get resolution from metadata if exists
- Returns:
Resolution or None if not found
- Return type:
Optional[float]
- get_metadata_segmentation_small_segment() int | None¶
Get segmentation small segment from metadata if exists
- Returns:
Segmentation small segment or None if not found
- Return type:
Optional[int]
- get_metadata_segmentation_threshold() float | None¶
Get segmentation threshold from metadata if exists
- Returns:
Segmentation threshold or None if not found
- Return type:
Optional[float]
- get_metadata_standarization_parameters() StandardizationParameters | None¶
Get standardization parameters from metadata if exists
- Returns:
Standardization parameters or None if not found
- Return type:
Optional[StandardizationParameters]
- get_metadata_tile_size() int | None¶
Get tile size from metadata if exists
- Returns:
Tile size or None if not found
- Return type:
Optional[int]
- get_metadata_tiles_overlap() int | None¶
Get tiles overlap from metadata if exists
- Returns:
Tiles overlap or None if not found
- Return type:
Optional[int]
- get_model_batch_size() int | None¶
Get batch size of the model
- Returns:
Batch size or None if not found (dynamic batch size)
- Return type:
Optional[int] | None
- classmethod get_model_type_from_metadata(model_file_path: str) str | None¶
Get model type from metadata
- Parameters:
model_file_path (str) – Path to the model file
- Returns:
Model type or None if not found
- Return type:
Optional[str]
- get_number_of_channels() int¶
Returns number of channels in the input layer
- Returns:
Number of channels in the input layer
- Return type:
int
- get_number_of_output_channels() List[int]¶
Returns number of channels in the output layer
- Returns:
Number of channels in the output layer
- Return type:
int
- get_output_shapes() List[tuple]¶
Get shapes of the outputs for the model
- Returns:
Shapes of the outputs (batch_size, channels, height, width)
- Return type:
List[tuple]
- get_outputs_channel_names() List[List[str]] | None¶
Get class names from metadata
- Returns:
List of class names for each model output or None if not found
- Return type:
List[List[str]] | None
- postprocessing(model_output: List) ndarray¶
Postprocess the model output.
- Parameters:
model_output (List) – Output from the (Regression) model
- Returns:
Output from the (Regression) model
- Return type:
np.ndarray
- preprocessing(tiles_batched: ndarray) ndarray¶
Preprocess the batch of images for the model (resize, normalization, etc)
- Parameters:
image (np.ndarray) – Batch of images to preprocess (N,H,W,C), RGB, 0-255
- Returns:
Preprocessed batch of image (N,C,H,W), RGB, 0-1
- Return type:
np.ndarray
- process(tiles_batched: ndarray)¶
Process a single tile image
- Parameters:
img (np.ndarray) – Image to process ([TILE_SIZE x TILE_SIZE x channels], type uint8, values 0 to 255)
- Returns:
Single prediction
- Return type:
np.ndarray