Skip to main content

PyTorch implementation of conditional random field for multiclass semantic segmenation.

Project description

crfseg: CRF layer for segmentation in PyTorch

Conditional random field (CRF) is a classical graphical model which allows to make structured predictions in such tasks as image semantic segmentation or sequence labeling.

You can learn about it in papers:

Installation

pip install crfseg

Usage

Can be easily used as differentiable (and moreover learnable) postprocessing layer of your NN for segmentation. It is adaptive to a number of input's spatial dimensions.

import torch
from crfseg import MeanFieldCRF

model = nn.Sequential(
    nn.Identity(),  # your foken awesome NN
    MeanFieldCRF()
)

batch_size, n_channels, spatial = 10, 1, (100, 100)
x = torch.zeros((batch_size, n_channels, *spatial))
log_proba = model(x)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crfseg-0.1.2.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

crfseg-0.1.2-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page