Giter Site home page Giter Site logo

kleinxin / segmentation_models.pytorch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qubvel/segmentation_models.pytorch

0.0 2.0 0.0 1.34 MB

Segmentation models with pretrained backbones. PyTorch.

License: MIT License

Python 99.87% Dockerfile 0.13%

segmentation_models.pytorch's Introduction

Segmentation models

Build Status Generic badge

Segmentation models is python library with Neural Networks for Image Segmentation based on PyTorch.

The main features of this library are:

  • High level API (just two lines to create neural network)
  • 4 models architectures for binary and multi class segmentation (including legendary Unet)
  • 30 available encoders for each architecture
  • All encoders have pre-trained weights for faster and better convergence

Table of content

  1. Quick start
  2. Examples
  3. Models
    1. Architectures
    2. Encoders
    3. Pretrained weights
  4. Models API
  5. Installation
  6. License

Quick start

Since the library is built on the PyTorch framework, created segmentation model is just a PyTorch nn.Module, which can be created as easy as:

import segmentation_models_pytorch as smp

model = smp.Unet()

Depending on the task, you can change the network architecture by choosing backbones with fewer or more parameters and use pretrainded weights to initialize it:

model = smp.Unet('resnet34', encoder_weights='imagenet')

Change number of output classes in the model:

model = smp.Unet('resnet34', classes=3, activation='softmax')

All models have pretrained encoders, so you have to prepare your data the same way as during weights pretraining:

from segmentation_models_pytorch.encoders import get_preprocessing_fn

preprocess_input = get_preprocessing_fn('renset18', pretrained='imagenet')

Examples

  • Training model for cars segmentation on CamVid dataset here.
  • Training model with Catalyst (high-level framework for PyTorch) - here.

Models

Architectures

Encoders

Type Encoder names
VGG vgg11, vgg13, vgg16, vgg19, vgg11bn, vgg13bn, vgg16bn, vgg19bn
DenseNet densenet121, densenet169, densenet201, densenet161
DPN dpn68, dpn68b, dpn92, dpn98, dpn107, dpn131
Inception inceptionresnetv2
ResNet resnet18, resnet34, resnet50, resnet101, resnet152
SE-ResNet se_resnet50, se_resnet101, se_resnet152
SE-ResNeXt se_resnext50_32x4d, se_resnext101_32x4d
SENet senet154

Weights

Weights name Encoder names
imagenet+5k dpn68b, dpn92, dpn107
imagenet * all other encoders

Models API

  • model.encoder - pretrained backbone to extract features of different spatial resolution
  • model.decoder - segmentation head, depends on models architecture (Unet/Linknet/PSPNet/FPN)
  • model.activation - output activation function, one of sigmoid, softmax
  • model.forward(x) - sequentially pass x through model`s encoder and decoder (return logits!)
  • model.predict(x) - inference method, switch model to .eval() mode, call .forward(x) and apply activation function with torch.no_grad()

Installation

PyPI version:

$ pip install segmentation-models-pytorch

Latest version from source:

$ pip install git+https://github.com/qubvel/segmentation_models.pytorch

License

Project is distributed under MIT License

Run tests

$ docker build -f docker/Dockerfile.dev -t smp:dev .
$ docker run --rm smp:dev pytest -p no:cacheprovider

segmentation_models.pytorch's People

Contributors

qubvel avatar vfdev-5 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.