Deep Leaarning segmentation architectures for PyTorch and FastAI
This repository contains different deep learning architectures definitions that can be applied to image segmentation.
In Deep-Tumour-Spheroid repository can be found and example of how to apply it with a custom dataset, in that case brain tumours images are used.
These architectures are classified as:
- Semantic Segmentation: each pixel of an image is linked to a class label.
- Instance Segmentation: is similar to semantic segmentation, but goes a bit deeper, it identifies , for each pixel, the object instance it belongs to.
- Salient Object Detection (Binary clases only): detection of the most noticeable/important object in an image.
🚀 Getting Started
To start using this package, install it using
For example, for installing it in Ubuntu use:
pip3 install SemTorch
This package creates an abstract API to access a segmentation model of different architectures. This method returns a FastAI 2 learner that can be combined with all the fastai's functionalities.
# SemTorch from semtorch import get_segmentation_learner learn = get_segmentation_learner(dls=dls, number_classes=2, segmentation_type="Semantic Segmentation", architecture_name="deeplabv3+", backbone_name="resnet50", metrics=[tumour, Dice(), JaccardCoeff()],wd=1e-2, splitter=segmentron_splitter).to_fp16()
You can find a deeper example in Deep-Tumour-Spheroid repository, in this repo the package is used for the segmentation of brain tumours.
def get_segmentation_learner(dls, number_classes, segmentation_type, architecture_name, backbone_name, loss_func=None, opt_func=Adam, lr=defaults.lr, splitter=trainable_params, cbs=None, pretrained=True, normalize=True, image_size=None, metrics=None, path=None, model_dir='models', wd=None, wd_bn_bias=False, train_bn=True, moms=(0.95,0.85,0.95)):
This function return a learner for the provided architecture and backbone
- dls (DataLoader): the dataloader to use with the learner
- number_classes (int): the number of clases in the project. It should be >=2
- segmentation_type (str): just
Semantic Segmentationaccepted for now
- architecture_name (str): name of the architecture. The following ones are supported:
- backbone_name (str): name of the backbone
- loss_func (): loss function.
- opt_func (): opt function.
- lr (): learning rates
- splitter (): splitter function for freazing the learner
- cbs (List[cb]): list of callbacks
- pretrained (bool): it defines if a trained backbone is needed
- normalize (bool): if normalization is applied
- image_size (int): REQUIRED for MaskRCNN. It indicates the desired size of the image.
- metrics (List[metric]): list of metrics
- path (): path parameter
- model_dir (str): the path in which save models
- wd (float): wieght decay
- wd_bn_bias (bool):
- train_bn (bool):
- moms (Tuple(float)): tuple of different momentuns
- learner: value containing the learner object
💼 Linkedin David Lacalle Castillo
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.