Tiny Binary Segmenter#

class glasses_detector.architectures.tiny_binary_segmenter.TinyBinarySegmenter[source]#

Bases: Module

Tiny binary segmenter.

This is a custom segmenter created with the aim to contain very few parameters while maintaining a reasonable accuracy. It only has several sequential up-convolution and down-convolution layers with residual connections and is very similar to U-Net.

Note

You can read more about U-Net architecture in the following paper by O. Ronneberger et al.: U-Net: Convolutional Networks for Biomedical Image Segmentation

forward(x: Tensor) dict[str, Tensor][source]#

Performs forward pass.

Predicts raw pixel scores for the given batch of inputs. Scores are unbounded - anything that’s less than 0 means positive class belonging to the pixel is unlikely and anything that’s above 0 indicates that positive class for a particular pixel is likely.

Parameters:

x (torch.Tensor) – Image batch of shape (N, C, H, W). Note that pixel values are normalized and squeezed between 0 and 1.

Returns:

A dictionary with a single “out” entry (for compatibility). The value is an output tensor of shape (N, 1, H, W) indicating which pixels in the image fall under positive category. The scores are unbounded, thus, to convert to probabilities, sigmoid function must be used.

Return type:

dict[str, torch.Tensor]