This is an implementation of PSPNet in TensorFlow for semantic segmentation on the cityscapes dataset. We first convert weight from Original Code by using caffe-tensorflow framework.
Support inference phase for ade20k dataset
using model of pspnet50 (convert weights from original author)- Using
tf.matmul
to decode label, so as to improve the speed of inference.
Support different input size
by padding input image to (720, 720) if original size is smaller than it, and get result by cropping image in the end.
Change bn layer from tf.nn.batch_normalization
into tf.layers.batch_normalization
in order to support training phase. Also update initial model in Google Drive.
Get restore checkpoint from Google Drive and put into model
directory. Note: Select the checkpoint corresponding to the dataset.
To get result on your own images, use the following command:
python inference.py --img-path=./input/test.png --dataset cityscapes
Inference time: ~0.6s
Options:
--dataset cityscapes or ade20k
--flipped-eval
--checkpoints /PATH/TO/CHECKPOINT_DIR
Perform in single-scaled model on the cityscapes validation datase.
Method | Accuracy |
---|---|
Without flip | 76.99% |
Flip | 77.23% |
To get evaluation result, you need to download Cityscape dataset from Official website first. Then change DATA_DIRECTORY
to your dataset path in evaluate.py
:
DATA_DIRECTORY = /Path/to/dataset
Then run the following command:
python evaluate.py
List of Args:
--flipped-eval - Using flipped evaluation method
--measure-time - Calculate inference time
Input image | Output image |
---|---|
Input image | Output image |
---|---|
Input image | Output image |
---|---|