Giter Club home page Giter Club logo

pytorch_deeplab's Introduction

PyTorch_DeepLab

This repo is old. Go check out my new model RegSeg that achieved SOTA on real-time semantic segmentation on Cityscapes.

Currently, the code supports DeepLabv3+ with many common backbones, such as Mobilenetv2, Mobilenetv3, Resnet, Resnetv2, XceptionAligned, Regnet, EfficientNet, and many more, thanks to the package timm. The code supports 3 datasets, namely PascalVoc, Coco, and Cityscapes.

I trained a few models on Cityscapes and PascalVoc, and will release the weights soon.

Results

Using separable convolution in the decoder reduces model size and the number of flops, but increases the memory requirement by 1 GB during training.

PascalVoc

To use the weights, click the link, and instantiate an object like the line below, changing the name, sc("separable convolution"), and the path to the pretrained weights that you just downloaded.

model=Deeplab3P(name='regnetx_040',num_classes=21,
sc=False,pretrained=pretrained_path).to(device)
name separable convolution mIOU weights
resnet50d yes 77.1 link
regnetx_040 yes 77.0 link
regnety_040 yes 78.6 link
regnetx_080 no 77.3 link
mobilenetv2 no 72.8 link

Installation

After cloning the repository, run the following command to install all dependencies. pip install -r requirements.txt

Datasets

COCO

run the command

sh coco_download.sh

We use the 21 classes that intersect PascalVoc's.

Cityscapes

go to https://www.cityscapes-dataset.com, create an account, and download gtFine_trainvaltest.zip and leftImg8bit_trainvaltest.zip. You can delete the test images to save some space if you don't want to submit to the competition. Name the directory cityscapes_dataset. Make sure that you have downloaded the required python packages and run

CITYSCAPES_DATASET=cityscapes_dataset csCreateTrainIdLabelImgs

There are 19 classes.

PascalVoc

Download the original dataset here.

Then download the augmented dataset here, and create a text file named train_aug.txt with this content.

Place train_aug.txt in VOCdevkit/VOC2012/ImageSets/Segmentation/train_aug.txt

Place SegmentationClassAug directory in VOCdevkit/VOC2012/SegmentationClassAug

There are 21 claases.

Credits to https://www.sun11.me/blog/2018/how-to-use-10582-trainaug-images-on-DeeplabV3-code/

Once you have downloaded the dataset

do one of the following three lines in train.py

data_loader, data_loader_test=get_coco(root,batch_size=16)
data_loader, data_loader_test=get_pascal_voc(root,batch_size=16)
data_loader, data_loader_test=get_cityscapes(root,batch_size=16)

where the root is usually "." or the top level directory name of the dataset.

To train a model yourself

Download one of the three datasets, change save_path, and num_classes in train.py if necessary, and run the command

python train.py

To resume training

In train.py, set resume=True, and change the resume_path to the save_path of your last train session.

pytorch_deeplab's People

Contributors

rolandgao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.