Functionnals
Here are functions that are used inside Predictor class and metrics.
Metrics
Here are all the functions that compose the processes above.
- detectools.metrics.functionnals.match_boxes(prediction: Format, target: Format, iou_threshold: float = 0.5) Tuple[Tensor, Tensor, Tensor, Tuple[Tensor, Tensor]][source]
Match better prediction boxes candidates with target boxes. Return indexes of prediction and target boxes that match and compute statistics of detection quality (Tp, FP, FN).
- Parameters:
- Returns:
Detection statsitics (TP, FN, FN) & prediction and target boxes indexes that match well.
- Return type:
Tuple[Tensor, Tensor, Tensor, Tuple[Tensor, Tensor]]
Inference
- detectools.inference.engine.add_offset(image: Tensor, offset: int) Tensor[source]
Pad fix number of pixels around sides of image :param image: Image to pad. :type image:
Tensor:param offset: Number of pixels to pad. :type offset:int- Returns:
Padded image.
- Return type:
Tensor
- detectools.inference.engine.remove_offset(image: Tensor, offset: int) Tensor[source]
Remove fix number of pixels on each side of image.
- Parameters:
image (
Tensor) – Image.offset (
int) – Border size to remove.image – Image to pad.
offset – Number of pixels to remove.
- Returns:
Image without offset.
- Return type:
Tensor
- Returns:
Cropped image.
- Return type:
Tensor
- detectools.inference.engine.pad_to(image: Tensor, size: Tuple, fill_value: int = 0) Tensor[source]
Pad Image with fill value to fit size with origin image in center of padded image.
- Parameters:
image (
Tensor) – Image to be padded.size (
Tuple) – Size to fit with padding.fill_value (
int, optional) – value to use for filling new pixels.image – Image to be padded.
size – Size to fit with padding.
fill_value – Value to use for filling new pixels. Defaults to 0.
- Returns:
Padded image
- Return type:
Tensor
- Returns:
Padded Image
- Return type:
Tensor
- detectools.inference.engine.crop_to(image: Tensor, size: Tuple) Tensor[source]
Crop Image in center.
- Parameters:
image (
Tensor) – Image to crop.size (
Tuple) – Cropped size.
- Returns:
Cropped Image.
- Return type:
Tensor
- detectools.inference.engine.patchification(image: Tensor, patch_size: Tuple, overlap: float) Tuple[Tensor, List[Tuple[int]], Tuple[int]][source]
Cut image in patches according to patch size and overlapping. If needed padding is applied to fit patch size multiplicator on H & W.
- Parameters:
image (
Tensor) – Large image to patchify.patch_size (
Tuple) – Size of patch.overlap (
float) – Overlap between patches.
- Returns:
Tensor of N patches (N, patch_height, patch_width)
Coordinates of patches.
- Return type:
Tuple[Tensor, List[Tuple[int]], Tuple[int]]
- detectools.inference.engine.unpatchification(predictions: List[BaseFormat], coordinates: List[Tuple[int]], spatial_size: Tuple[int]) BaseFormat[source]
Build a prediction from multiple patch predictions and coordinates.
- Parameters:
predictions (
List[BaseFormat]) – Patches predictions.coordinates (
List[Tuple[int]]) – List of Y, X coordinates.spatial_size (
Tuple[int]) – Size of merged prediction.
- Returns:
BaseFormat of whole image.
- Return type:
BaseFormat