/PSPNet-Keras

Primary LanguagePythonMIT LicenseMIT

Keras implementation of PSPNet(caffe)

Implemented Architecture of Pyramid Scene Parsing Network in Keras.

Converted trained weights are needed to run the network.

Weights of the original caffemodel can be converted with weight_converter.py as follows:

python weight_converter.py <path to .prototxt> <path to .caffemodel>

Running this needs the compiled original PSPNet caffe code and pycaffe. Already converted weights can be downloaded here:

pspnet50_ade20k.npy pspnet101_cityscapes.npy pspnet101_voc2012.npy

npy weights should be placed in the directory weights/npy.

The interpolation layer is implemented as custom layer "Interp"

Keras result:

Original New New New

Original New New New

Original New New New

Pycaffe result:

Pycaffe results

Dependencies:

  1. Tensorflow (-gpu)
  2. Keras
  3. numpy
  4. scipy
  5. pycaffe(PSPNet)(optional for converting the weights)
pip install -r requirements.txt --upgrade

Usage:

python pspnet.py
python pspnet.py -m pspnet101_cityscapes -i example_images/cityscapes.png -o example_results/cityscapes.jpg
python pspnet.py -m pspnet101_voc2012 -i example_images/pascal_voc.jpg -o example_results/pascal_voc.jpg