segmentation_models.pytorch (qubvel-org/segmentation_models.pytorch)

Searching Database…

What is this?A Python library for building image semantic segmentation models in PyTorch, with over 500 pretrained convolutional and transformer-based backbones.
Is this a framework or a library I just import?It is a library: you import it in your own PyTorch training code and get a model object (torch.nn.Module), not a standalone app or training framework.
How do I create a segmentation model with it?Install it, then create a model in two lines by picking an architecture (e.g. Unet, DeepLabV3+, Segformer) and an encoder/backbone, then plug it into your own PyTorch training loop.
Do I need PyTorch already set up to use this?Yes, it's built on top of PyTorch, and many of its 500+ encoders are supported via the timm library.
Does it include training code or just model building blocks?It only provides model architectures, encoders, losses and metrics as building blocks; you still write your own training loop in your framework of choice.
Is the whole repo MIT licensed?Mostly MIT, but some files are under other licenses, so check carefully especially for commercial use.
Which model architectures are supported?12 architectures including Unet, Unet++, MAnet, Linknet, FPN, PSPNet, PAN, DeepLabV3, DeepLabV3+, UPerNet, Segformer, and DPT.
Can I change the number of input channels, like for grayscale or multispectral images?Yes, the in_channels parameter lets a model accept any number of channels, and pretrained ImageNet weights are automatically adapted (summed for 1-channel input or tiled/scaled for other counts).
Can models also output a classification label alongside the segmentation mask?Yes, setting aux_params creates an auxiliary classification head (GlobalPooling -> Dropout -> Linear -> Activation) that outputs a label in addition to the mask.
Can I export a trained model to ONNX?Yes, the library is designed to be ONNX export and torch script/trace/compile friendly, and there's an example notebook for exporting to ONNX.
Creator
qubvel-org
Size
16.3 MB
Stars
11.8K
Age
7y
Commits · 90 Days