contrastsegpaddle

September 16, 2021 · View on GitHub

English | 简体中文

1 Introduction

images
This project reproduces HRNet_W48_Contrast based on paddlepaddle framework. The core idea of pixel-wise contrastive algorithm is to force pixel embeddings belonging to a same semantic class to be more similar than embeddings from different classes. It has two advantages. Firstly, pixel-wise contrastive algorithm can address the categorization ability of individual pixel embeddings. Secondly, pixel embeddings be well structured to addrress intra-class compactness and inter-class dispersion.

Paper:

Reference project:

2 Accuracy

This index is test in the val set of CityScapes. HRNet_W48 was pretrained in ImageNet.

stepsoptimage_sizebatch_sizedatasetmemorycardmIouconfig
HRNet_W48_contrast60ksgd1024x5122CityScapes32G40.8266HRNet_W48_cityscapes_1024x512_60k.yml

3 Dataset

CityScapes dataset

  • Dataset size:
    • train: 2975
    • val: 500

4 Environment

  • Hardware: Tesla V100 * 4

  • Framework:

    • PaddlePaddle == 2.1.2

5 Quick start

step1: clone

# clone this repo
git clone https://github.com/justld/contrast_seg_paddle.git
cd contrast_seg_paddle

Install packages

pip install -r requirements.txt

step2: train

python train.py --config configs/HRNet_W48_cityscapes_1024x512_60k.yml  --do_eval --use_vdl --log_iter 100 --save_interval 1000 --save_dir output

If you want to train distributed and use multicards:

python -m paddle.distributed.launch train.py --config configs/HRNet_W48_cityscapes_1024x512_60k.yml  --do_eval --use_vdl --log_iter 100 --save_interval 1000 --save_dir output

step3: test

You can download the pretrained model in BaiduYun. (Extraction code: hwq7)

python val.py --config configs/HRNet_W48_cityscapes_1024x512_60k.yml --model_path output/best_model/model.pdparams

6 Code structure

Structure

├─configs                          
├─images                         
├─output                           
├─paddleseg                                                   
│  export.py                     
│  predict.py                        
│  README.md                        
│  README_CN.md                     
│  requirements.txt                      
│  setup.py                   
│  train.py                
│  val.py                       

7 Model information

For other information about the model, please refer to the following table:

informationdescription
Authordu lang
Date2021.09
Framework versionPaddle 2.1.2
Application scenariosSemantic Segmentation
Support hardwareGPU、CPU
Online operationnotebook, Script