PSPNet in Chainer

Overview

PSPNet

This is an unofficial implementation of Pyramid Scene Parsing Network (PSPNet) in Chainer.

Training

Requirement

  • Python 3.4.4+
    • Chainer 3.0.0b1+
    • ChainerMN master
    • CuPy 2.0.0b1+
    • ChainerCV 0.6.0+
    • NumPy 1.12.0+
    • tqdm 4.11.0+
pip install chainer --pre
pip install cupy --pre
pip install git+git://github.com/chainer/chainermn
pip install git+git://github.com/chainer/chainercv
pip install tqdm

Inference using converted weights

Requirement

  • Python 3.4.4+
    • Chainer 3.0.0b1+
    • ChainerCV 0.6.0+
    • Matplotlib 2.0.0+
    • CuPy 2.0.0b1+
    • tqdm 4.11.0+

1. Run demo.py

Cityscapes

$ python demo.py -g 0 -m cityscapes -f aachen_000000_000019_leftImg8bit.png

Pascal VOC2012

$ python demo.py -g 0 -m voc2012 -f 2008_000005.jpg

ADE20K

$ python demo.py -g 0 -m ade20k -f ADE_val_00000001.jpg

FAQ

If you get RuntimeError: Invalid DISPLAY variable, how about specifying the matplotlib's backend by an environment variable?

$ MPLBACKEND=Agg python demo.py -g 0 -m cityscapes -f aachen_000000_000019_leftImg8bit.png

Convert weights by yourself

Caffe is NOT needed to convert .caffemodel to Chainer model. Use caffe_pb2.py.

Requirement

  • Python 3.4.4+
    • protobuf 3.2.0+
    • Chainer 3.0.0b1+
    • NumPy 1.12.0+

1. Download the original weights

Please download the weights below from the author's repository:

and then put them into weights directory.

2. Convert weights

$ python convert.py

Reference

  • The original implementation by authors is: hszhao/PSPNet
  • The original paper is:
    • Hengshuang Zhao, Jianping Shi, Xiaojuan Qi, Xiaogang Wang, Jiaya Jia, "Pyramid Scene Parsing Network", Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017
You might also like...
Comments
  • Training failes with ModuleNotFoundError when using train_mn.py

    Training failes with ModuleNotFoundError when using train_mn.py

    Hi, I got following error when I tried to train PSP net with your train_mn.py How can I train my PSPNet model?

    root@5e6e3385ca5a:/yendo/oss/chainer-pspnet# python3 train_mn.py --result_dir result configs/cityscapes/pspnet.yml
    Warning: using naive communicator because only naive supports CPU-only execution
    ==========================================
    Num process (COMM_WORLD): 1
    Using single_node communicator
    Chainer version: 3.4.0
    ChainerMN version: 1.2.0
    cuda: True, cudnn: True
    result_dir: result
    Traceback (most recent call last):
      File "train_mn.py", line 504, in <module>
        trainer = get_trainer(args)
      File "train_mn.py", line 374, in get_trainer
        model = get_model_from_config(config, comm)
      File "train_mn.py", line 239, in get_model_from_config
        loss.module, loss.name, loss.args, comm)
      File "train_mn.py", line 219, in get_model
        mod = import_module(loss_module)
      File "/root/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'loss'
    
    opened by jo7ueb 0
  • Training Fails with IndexError when using train.py

    Training Fails with IndexError when using train.py

    Hi, I got following error when I tried to train PSP net with your train.py How can I train my PSPNet model?

    root@9bdbca328f5f:/yendo/oss/chainer-pspnet# python3 train.py --gpu --result_dir result configs/cityscapes/pspnet.yml
    ==========================================
    Chainer version: 3.4.0
    CuPy version: 2.4.0
    Traceback (most recent call last):
      File "train.py", line 483, in <module>
        trainer = get_trainer(args)
      File "train.py", line 339, in get_trainer
        chainer.cuda.available, chainer.cuda.cudnn_enabled, ))
    IndexError: tuple index out of range
    
    opened by jo7ueb 0
  • could you actually train a new model?

    could you actually train a new model?

    Hi, I am currently trying to train the cityscapes dataset with your code, but the result is miserable: still 0.5263158 (=1/19) class accuracy after 120 epochs. Apparently, the loss of training data is converged correctly, so it seems like a perfect over fitting. Since I used the same settings as yours, i am wondering how you managed to reproduce the results(maybe i need less learning rate?). thanks in advance!

    opened by suzukikbp 0
Owner
Shunta Saito
Ph.D in Engineering, Researcher at Preferred Networks, Inc.
Shunta Saito
Tensorboard for pytorch (and chainer, mxnet, numpy, ...)

tensorboardX Write TensorBoard events with simple function call. The current release (v2.3) is tested on anaconda3, with PyTorch 1.8.1 / torchvision 0

Tzu-Wei Huang 7.5k Dec 28, 2022
PyTorch implementation of PSPNet segmentation network

pspnet-pytorch PyTorch implementation of PSPNet segmentation network Original paper Pyramid Scene Parsing Network Details This is a slightly different

Roman Trusov 532 Dec 29, 2022
tensorboard for pytorch (and chainer, mxnet, numpy, ...)

tensorboardX Write TensorBoard events with simple function call. The current release (v2.1) is tested on anaconda3, with PyTorch 1.5.1 / torchvision 0

Tzu-Wei Huang 7.5k Jan 7, 2023
ChainerRL is a deep reinforcement learning library built on top of Chainer.

ChainerRL ChainerRL is a deep reinforcement learning library that implements various state-of-the-art deep reinforcement algorithms in Python using Ch

Chainer 1.1k Dec 26, 2022
Tensorboard for pytorch (and chainer, mxnet, numpy, ...)

tensorboardX Write TensorBoard events with simple function call. The current release (v2.3) is tested on anaconda3, with PyTorch 1.8.1 / torchvision 0

Tzu-Wei Huang 7.5k Dec 28, 2022