• Stars
    star
    146
  • Rank 252,769 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 6 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Google DeepLab V3 for Image Semantic Segmentation

DeepLab V3

Lei Mao, Shengjie Lin

University of Chicago

Toyota Technological Institute at Chicago

Introduction

DeepLab is a series of image semantic segmentation models, whose latest version, i.e. v3+, proves to be the state-of-art. Its major contribution is the use of atrous spatial pyramid pooling (ASPP) operation at the end of the encoder. While the model works extremely well, its open source code is hard to read (at least from my personal perspective). Here we re-implemented DeepLab V3, the earlier version of v3+ (which only additionally employs the decoder architecture), in a much simpler and more understandable way.

Dependencies

  • Python 3.5
  • TensorFlow 1.8
  • Tqdm 4.26.0
  • Numpy 1.14
  • OpenCV 3.4.3
  • Pillow 5.3.0

Files

.
├── archieved
├── download.py
├── feature_extractor.py
├── LICENSE.md
├── model.py
├── modules.py
├── nets
├── README.md
├── test_demo.py
├── test_any_image.py
├── train.py
└── utils.py

The nets directory contains network definition files that are directly copied from tensorflow/models/research/slim/nets

Usages

Install Dependencies

To install dependencies, please run the following command to install everything required automatically:

$ chmod +x install_dependencies.sh
$ pip install -r requirements.txt
$ ./install_dependencies.sh

If found permission problems, please run the following command instead:

$ chmod +x install_dependencies.sh
$ pip install -r requirements.txt
$ sudo ./install_dependencies.sh

Download Dataset

Download and extract VOC2012 dataset, SBD dataset, and pretrained models to designated directories.

$ python download.py --help
usage: download.py [-h] [--downloads_dir DOWNLOADS_DIR] [--data_dir DATA_DIR]
                   [--pretrained_models_dir PRETRAINED_MODELS_DIR]
                   [--pretrained_models PRETRAINED_MODELS [PRETRAINED_MODELS ...]]

Download DeepLab semantic segmentation datasets and pretrained backbone
models.

optional arguments:
  -h, --help            show this help message and exit
  --downloads_dir DOWNLOADS_DIR
                        Downloads directory
  --data_dir DATA_DIR   Data directory
  --pretrained_models_dir PRETRAINED_MODELS_DIR
                        Pretrained models directory
  --pretrained_models PRETRAINED_MODELS [PRETRAINED_MODELS ...]
                        Pretrained models to download: resnet_50, resnet_101,
                        mobilenet_1.0_224

For example, to download and extract datasets and models into directories specified:

$ python download.py --downloads_dir ./downloads --data_dir ./data --pretrained_models_dir ./models/pretrained --pretrained_models resnet_50 resnet_101 mobilenet_1.0_224

For simplicity, please just run the following command in terminal:

$ python download.py

Train Model

$ python train.py --help
usage: train.py [-h] [--network_backbone NETWORK_BACKBONE]
                [--pre_trained_model PRE_TRAINED_MODEL]
                [--trainset_filename TRAINSET_FILENAME]
                [--valset_filename VALSET_FILENAME] [--images_dir IMAGES_DIR]
                [--labels_dir LABELS_DIR]
                [--trainset_augmented_filename TRAINSET_AUGMENTED_FILENAME]
                [--images_augmented_dir IMAGES_AUGMENTED_DIR]
                [--labels_augmented_dir LABELS_AUGMENTED_DIR]
                [--model_dir MODEL_DIR] [--log_dir LOG_DIR]
                [--random_seed RANDOM_SEED]

Train DeepLab V3 for image semantic segmantation.

optional arguments:
  -h, --help            show this help message and exit
  --network_backbone NETWORK_BACKBONE
                        Network backbones: resnet_50, resnet_101,
                        mobilenet_1.0_224. Default: resnet_101
  --pre_trained_model PRE_TRAINED_MODEL
                        Pretrained model directory
  --trainset_filename TRAINSET_FILENAME
                        Train dataset filename
  --valset_filename VALSET_FILENAME
                        Validation dataset filename
  --images_dir IMAGES_DIR
                        Images directory
  --labels_dir LABELS_DIR
                        Labels directory
  --trainset_augmented_filename TRAINSET_AUGMENTED_FILENAME
                        Train augmented dataset filename
  --images_augmented_dir IMAGES_AUGMENTED_DIR
                        Images augmented directory
  --labels_augmented_dir LABELS_AUGMENTED_DIR
                        Labels augmented directory
  --model_dir MODEL_DIR
                        Trained model saving directory
  --log_dir LOG_DIR     TensorBoard log directory
  --random_seed RANDOM_SEED
                        Random seed for model training.

For simplicity, please run the following command in terminal:

$ python train.py

With learning rate of 1e-5, the mIOU could be greater 0.7 after 20 epochs, which is comparable to the test statistics of DeepLab V3 in the publication.

Demos

To show some demos, please run the following command in terminal:

$ python test_demo.py
Image Label Prediction
Image Label Prediction
Image Label Prediction
Image Label Prediction

Custom Demo

Just put some JPG-format images into demo_dir and run the following command in the terminal.

$ python test_any_image.py

Results will be written into same folder. Make sure that proper model trained and a checkpoint is saved in models_dir. See the script for details.

Contributed by pinaxe1. Will modify to accept arguments and multiple image formats.

References

L.-C. Chen, G. Papandreou, I. Kokkinos, K. Murphy, and A. L. Yuille. Deeplab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs. TPAMI, 2017.

L.-C. Chen, G. Papandreou, F. Schroff, and H. Adam. Rethinking Atrous Convolution for Semantic Image Segmentation. arXiv:1706.05587, 2017.

L.-C. Chen, Y. Zhu, G. Papandreou, F. Schroff, H. Adam. Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation. arXiv:1802.02611, 2018.

To-Do List

  • Test script for new arbitrary test images.

More Repositories

1

Voice-Converter-CycleGAN

Voice Converter Using CycleGAN and Non-Parallel Data
Python
524
star
2

Frozen-Graph-TensorFlow

Save, Load Frozen Graph and Run Inference From Frozen Graph in TensorFlow 1.x and 2.x
Python
299
star
3

ONNX-Runtime-Inference

ONNX Runtime Inference C++ Example
C++
215
star
4

Particle-Filter

Robot Localization in Maze Using Particle Filter
Python
123
star
5

PyTorch-Quantization-Aware-Training

PyTorch Quantization Aware Training Example
Python
119
star
6

Console-Snake

Snake Game in Console Implemented Using C++
C++
114
star
7

CUDA-GEMM-Optimization

CUDA Matrix Multiplication Optimization
Cuda
110
star
8

Two-Layer-Hierarchical-Softmax-PyTorch

Two-Layer Hierarchical Softmax Implementation for PyTorch
Python
68
star
9

Singing-Voice-Separation-RNN

Singing-Voice Separation From Monaural Recordings Using Deep Recurrent Neural Networks
Python
60
star
10

Rotated-Rectangle-Crop-OpenCV

Rotated Rectangle Crop Function for OpenCV
Python
52
star
11

PyTorch-Pruning-Example

PyTorch Pruning Example
Python
46
star
12

gRPC-Examples

gRPC Beginner's C++ Examples with CMake
C++
45
star
13

Sampled-Softmax-PyTorch

Sampled Softmax Implementation for PyTorch
Python
43
star
14

PyTorch-Static-Quantization

PyTorch Static Quantization Example
Python
39
star
15

LibTorch-ResNet-CIFAR

ResNet Implementation, Training, and Inference Using LibTorch C++ API
C++
34
star
16

Docker-WeChat

Run WeChat Using Docker
Dockerfile
34
star
17

Protocol-Buffer-Examples

Google Protocol Buffer 3.0 Beginner's C++ and Python Examples with CMake
Python
31
star
18

CPP-Debug-Docker

Debug C/C++ Programs In Docker
C++
26
star
19

Wine-Docker-Image

Wine Docker Image to Run Windows Applications
Dockerfile
23
star
20

TensorRT-Custom-Plugin-Example

Quick and Self-Contained TensorRT Custom Plugin Implementation and Integration
C++
23
star
21

Simple-Inference-Server

Inference Server Implementation from Scratch for Machine Learning Models
Python
23
star
22

Siamese_Network_MNIST

Siamese Network on MNIST Dataset
Python
17
star
23

Boost-Docker

Docker for Boost C++ Library
Dockerfile
17
star
24

Nsight-Systems-Docker-Image

Nsight Systems in Docker
Dockerfile
17
star
25

Sphinx-CPP-TriangleLib

Using Sphinx to Document C++ Libraries
C++
15
star
26

ONNX-Python-Examples

ONNX Python Examples
Dockerfile
15
star
27

PPMIO

PPM Image I/O Library for C/C++
C++
14
star
28

What-Is-The-Date-Today

GitHub Self-Updating Repository Using GitHub Scheduled Actions
12
star
29

OpenAI_Gym_AI

These are my learning algorithm solutions to OpenAI Gym environments.
Python
11
star
30

PyTorch-Eager-Mode-Quantization-TensorRT-Acceleration

TensorRT Acceleration for PyTorch Native Eager Mode Quantization Models
Python
11
star
31

Nsight-Compute-Docker-Image

Nsight Compute in Docker
Dockerfile
11
star
32

Tensorflow_Assignment_Solutions

These are my solutions to all six assignments of tensorflow tutorial in Udacity, covering CNN, RNN, Regularization (L2 and dropout), Embeddings (word2vec) and Seq2Seq LSTM (bigrams prediction and sequence mirror)
Jupyter Notebook
10
star
33

Doxygen-CPP-TriangleLib

Using Doxygen to Document C++ Libraries
C++
10
star
34

Image-Converter-CycleGAN

Image Converter Using CycleGAN and Non-Parallel Data
Python
9
star
35

PyTorch-Dynamic-Quantization

PyTorch Dynamic Quantization Example
Python
9
star
36

Ramachandran

Ramachandran Plot Tool
Python
8
star
37

CPP-Treasure-Bay

A Collection of C++ Basic and Advanced Usages
C++
7
star
38

TensorFlow_Dataset_API_Demo

Efficient Dataset Loading Using TensorFlow Dataset API
Python
6
star
39

Flappy_Bird_AI

Flappy Bird Artificial Intelligence
Python
5
star
40

DockerFiles

Collection of Dockerfiles Used for Different Purposes
Dockerfile
5
star
41

Console-Player

Audio Player in Console Implemented Using C/C++
C++
5
star
42

TensorRT-Docker-Image

TensorRT in Docker
Dockerfile
5
star
43

Pixabay-AsyncIO-Download

Download Pixabay Images Using Python AsyncIO
Python
5
star
44

PyTorch-Automatic-Mixed-Precision-Training

PyTorch Automatic Mixed Precision Training Example
Python
5
star
45

Dota2-Profile-Pictures

Dota2ćäž»æ’­ć€ŽćƒïŒŒéƒšćˆ†çš€æœ‰ïŒŒæ‰Žćźžă€‚
Shell
4
star
46

Auto-Red-Eye-Remover

Automatic Red Eye Removal From Photos Using C++ and OpenCV
C++
4
star
47

Drunken-Sniper

Modified 64.0 Game Implemented Using Jack Language and Run in Nand2Tetris VM Emulator
HTML
4
star
48

Convolutional_Neural_Network_CIFAR10

Object-Oriented Convolutional Neural Network for CIFAR10 Dataset
Python
4
star
49

Sphinx-Python-TriangleLib

Using Sphinx to Document Python Libraries
Python
4
star
50

Intelligent_Mouse

Maze Explorer and Solver
Jupyter Notebook
3
star
51

CMake-Examples

CMake Examples for Noobs
CMake
3
star
52

Heroku-Docker-Example

Deploy Docker Applications on Heroku
Python
3
star
53

ABI-Breaking-Change-Demo

ABI Breaking Change Demo
C++
3
star
54

Image_Resizer

Image Resizer Web App Coded in Python
Python
2
star
55

leimao

2
star
56

PNGs_to_GIF

This is a script that transforms png-formatted images to gif-formatted animated image.
Python
2
star
57

Docker-Chess

Playing Chess Using SCID-VS-PC in Docker Container
Dockerfile
2
star
58

CPP-Public-Header-Abstract-Class-Declarations-Example

Using Abstract Class Declarations for Hiding Private Methods and Members
C++
2
star
59

Decision_Tree_Python

Efficient Implementation of Decision Tree from Scratch in Python
Python
2
star
60

Directory-Tree-Printer

Useful Directory Tree Printer
C++
2
star
61

Blog-Images

Hosting Images for Lei Mao's Log Book
JavaScript
2
star
62

MPCS_Programming_Placement_Exam

These are my solutions to the programming placement exam of the MPCS program at The University of Chicago.
HTML
2
star
63

Di-Tech_Algorithm_Challenge_2016

Didi Taxi is a mobile platform taxi-calling application in China. It has acquired Uber's China operations in 2016 with the capital from Apple. It hosted an machine learning algorithm contest in 2016 in order to solve the demand-supply problem of Didi taxi. I took part in the contest in 2016 when I was still studying at Duke University. This is my solution to the problem. My teammates also includes Guotu Li from Duke University and Jianhai Zhang from Dalian University of Technology.
Jupyter Notebook
2
star
64

UD282_Java_Programming_Basics

Assignment Solutions for UD282 Java Programming Basics at Udacity
Java
1
star
65

PyTorch-Automatic-Differentiation

PyTorch Automatic Differentiation Forward Mode and Reverse Mode Using autograd and functorch
Python
1
star
66

WikiMidas

Wikipedia Data Crawler
Python
1
star
67

TTIC_Deep_Learning_2018_Pareto_Competition

2018 Fundamentals of Deep Learning (TTIC 31230) Course Project - Language Modeling
Python
1
star
68

Thinkpad_Manuals

Thinkpad Manuals
1
star
69

Audience_SQL_Database

Audience SQL Database is a SQLite3 database designed for the management of the information of the VIP audience of China Dalian TV.
Python
1
star
70

Deep_Learning_Papers

Library of Deep Learning Papers
1
star
71

Automated_Environment_Configurations

Environment Configuration Bash Scripts for New Operating Systems
Shell
1
star
72

Image_Blurring_CUDA

RGB Image Blurring Using CUDA and CMake
Cuda
1
star
73

Stanford_CS229_Machine_Learning

Stanford CS229 Machine Learning Course Materials @ http://cs229.stanford.edu/materials.html
MATLAB
1
star
74

Logistic_Regression_Python

Efficient Implementation of Logistic Regression from Scratch in Python
Python
1
star
75

Document_Clustering_and_Retrieval

This is an unsupervised learning project to cluster and retrieve documents of similar topics. This is also my solution to the Document Clustering and Retrieval project in Machine Learning Specialization Courses at Coursera.
Jupyter Notebook
1
star
76

Semantic-Segmentation-CARLA

Semantic Segmentation Using CARLA Synthetic Dataset
Python
1
star
77

Data_Structures_and_Algorithms

These are the solutions to the assignments in Coursera Data Structures and Algorithms Specialization.
C++
1
star
78

MoeGirlMidas

MoeGirlMidas is a spidering program to crawl fictional characters' data from MoeGirl (https://zh.moegirl.org/Mainpage).
Jupyter Notebook
1
star
79

SPIEC_EASI_Analysis

This is a R and Python script to analyze the associations between different microbiome taxonomies using SPIEC-EASI.
Jupyter Notebook
1
star
80

PyTorch-Variational-Autoencoder

PyTorch Variational Autoencoder Example
Python
1
star
81

XLSX_to_CSVs

Transform the worksheets in Excel xlsl file to multiple csv files.
Python
1
star
82

Python_for_Everybody_Capstone

This is the capstone projects for the "Python for Every Body" Coursera Specialization. It includes some basic codes for data crawling from the web and data visualization using Python.
JavaScript
1
star