PyTorch implementation of semantic segmentation models.
This repository aims to implement semantic segmentation models with PyTorch.
- Hardware (Developer environment)
- CPU: Intel Core i7 9700
- RAM: 32GiB
- GPU: Nvidia Geforce RTX 3090
- Storage: Samsung SSD 970 Pro 512GB
- Software
- OS: Ubuntu (Primary), Windows (Secondary)
- Miniconda (Python 3.8)
- PyTorch 1.8.1 (CUDA 11.1)
- Dependent packages
- Matplotlib
- PyYAML
- Scikit-learn
- Tensorboard
- Tqdm
- Useful packages
- pytorch-summary
- flops-counter.pytorch
- Netron : Visualizer for neural network models. (web version: Netron)
This repository supports these semantic segmentation models as follows:
- (U-Net) Convolutional Networks for Biomedical Image Segmentation [Paper]
- (AR U-Net) Atrous Residual U-Net for Semantic Segmentation in Urban Street Scenes [Paper]
- (DeepLab V3) Rethinking Atrous Convolution for Semantic Image Segmentation [Paper]
- (DeepLab V3+) Encoder-Decoder with Atrous Separable Convolution for Semantic Segmentation [Paper]
This repository supports these datasets as follows:
-
-
Download dataset files. (leftImg8bit_trainvaltest.zip and gtFine_trainvaltest.zip).
-
Extract downloaded files. The structure of dataset is as follows:
|-- data | |-- cityscapes | | |-- gtFine | | | |-- test | | | |-- train | | | |-- val | | |-- leftImg8bit | | | |-- test | | | |-- train | | | |-- val | | |-- license.txt | | |-- README
-
Download cityscapesScripts for inspection, preparation, and evaluation. (or clone this repo)
-
Edit the script
labels.py
to specify the label number. -
Edit the script
createTrainIdLabelImgs.py
to set cityscapes path. -
Run the script
createTrainIdLabelImgs.py
to create annotations based on the training labels.
-
-
Clone this repository.
git clone https://github.com/synml/segmentation-pytorch
-
Create and activate a new virtual environment with Miniconda.
conda create -n [env_name, ex: torch] python=3.8 conda activate [env_name, ex: torch]
-
Install PyTorch.
-
Install the dependent packages mentioned above.
conda install matplotlib pyyaml scikit-learn tensorboard tqdm
-
Prepare datasets.
- Please refer to Datasets section.
-
Customize the configuration file. (config.yaml)
dataset: image_size: 400x800 # rows x cols num_classes: 20 # 19 + 1 (background) num_workers: 8 # number of CPU cores root: ../../data/cityscapes # dataset path model: UNet # options [UNet, AR_UNet, DeepLabV3, DeepLabV3plus] amp_enabled: True # Automatic Mixed Precision UNet: # Match model name batch_size: 16 epoch: 100 optimizer: name: Adam # options [SGD, Adam] lr: 0.001 weight_decay: 0.00001 <optimizer_keyarg1>:<value> scheduler: name: ReduceLROnPlateau factor: 0.5 patience: 5 min_lr: 0.00005 pretrained_weights: weights/UNet_best.pth Backbone: batch_size: 16 epoch: 100 optimizer: name: Adam lr: 0.001 weight_decay: 0.00001 scheduler: name: ReduceLROnPlateau factor: 0.5 patience: 5 min_lr: 0.00005 pretrained_weights: weights/Backbone_val_best.pth Proposed: batch_size: 8 epoch: 100 optimizer: name: Adam lr: 0.0005 weight_decay: 0.00001 scheduler: name: ReduceLROnPlateau factor: 0.5 patience: 5 min_lr: 0.00005 pretrained_weights: weights/Proposed_best.pth
-
backup.py
-
clean.py
-
demo.py
-
eval.py
-
exec_tensorboard.py
-
featurte_visualizer.py
-
train.py
-
train_interupter.ini
- https://github.com/meetshah1995/pytorch-semseg
- https://github.com/warmspringwinds/pytorch-segmentation-detection
- https://github.com/xiaoyufenfei/Efficient-Segmentation-Networks
- https://github.com/milesial/Pytorch-UNet
- Fork this repository.
- Create a new branch or use the master branch.
- Commit modifications.
- Push on the selected branch.
- Please send a pull request.
You can find more information in LICENSE
.