Giter Site home page Giter Site logo

backboned-unet's Introduction

backboned-unet

U-Nets for image segmentation with pre-trained backbones in PyTorch.

Why another U-Net implementation?

I was looking for an U-Net PyTorch implementation that can use pre-trained torchvision models as backbones in the encoder path. There is a great repo for this in Keras, but I didn't find a good PyTorch implementation that works with multiple torchvision models. So I decided to create one.

WIP

So far VGG, ResNet and DenseNet backbones have been implemented.

Setup

Installing package:

git clone https://github.com/mkisantal/backboned-unet.git
cd backboned-unet
pip install .

Simple usage example

The U-net model can be imported just like any other torchvision model. The user can specify a backbone architecture, choose upsampling operation (transposed convolution or bilinear upsampling followed by convolution), specify the number of filters in the different decoder stages, etc.

from backboned_unet import Unet
net = Unet(backbone_name='densenet121', classes=21)

The module loads the backbone torchvision model, and builds a decoder on top of it using specified internal features of the backbone.

Results on Pascal VOC

The figure below illustrates the training results for U-Nets with different ImageNet pretrained backbones.

pascal training

Setup:

network = Unet(backbone_name=model_name, classes=21, decoder_filters=(512, 256, 128, 64, 32)
criterion = torch.nn.CrossEntropyLoss(ignore_index=255)
optimizer = torch.optim.Adam([{'params': network.get_pretrained_parameters(), 'lr':1e-5},
                              {'params': network.get_random_initialized_parameters()}], lr=1e-4)

Images were resized to 224x224. Batch size 32. No dataset augmentation. IoU is calculated with the background ignored.

Example segmentation results:

pascal results

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.