Gated-Shape CNN for Semantic Segmentation (ICCV 2019)

Overview

GSCNN

This is the official code for:

Gated-SCNN: Gated Shape CNNs for Semantic Segmentation

Towaki Takikawa, David Acuna, Varun Jampani, Sanja Fidler

ICCV 2019 [Paper] [Project Page]

GSCNN DEMO

Based on based on https://github.com/NVIDIA/semantic-segmentation.

License

Copyright (C) 2019 NVIDIA Corporation. Towaki Takikawa, David Acuna, Varun Jampani, Sanja Fidler
All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).

Permission to use, copy, modify, and distribute this software and its documentation
for any non-commercial purpose is hereby granted without fee, provided that the above
copyright notice appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation, and that the name of the author
not be used in advertising or publicity pertaining to distribution of the software
without specific, written prior permission.

THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
~                                                                             

Usage

Clone this repo
git clone https://github.com/nv-tlabs/GSCNN
cd GSCNN

Python requirements

Currently, the code supports Python 3

  • numpy
  • PyTorch (>=1.1.0)
  • torchvision
  • scipy
  • scikit-image
  • tensorboardX
  • tqdm
  • torch-encoding
  • opencv
  • PyYAML

Download pretrained models

Download the pretrained model from the Google Drive Folder, and save it in 'checkpoints/'

Download inferred images

Download (if needed) the inferred images from the Google Drive Folder

Evaluation (Cityscapes)

python train.py --evaluate --snapshot checkpoints/best_cityscapes_checkpoint.pth

Training

A note on training- we train on 8 NVIDIA GPUs, and as such, training will be an issue with WiderResNet38 if you try to train on a single GPU.

If you use this code, please cite:

@article{takikawa2019gated,
  title={Gated-SCNN: Gated Shape CNNs for Semantic Segmentation},
  author={Takikawa, Towaki and Acuna, David and Jampani, Varun and Fidler, Sanja},
  journal={ICCV},
  year={2019}
}
Comments
  • Error trying to run code

    Error trying to run code

    `/usr/local/lib/python3.5/dist-packages/torch/nn/modules/loss.py:217: UserWarning: NLLLoss2d has been deprecated. Please use NLLLoss instead as a drop-in replacement and see https://pytorch.org/docs/master/nn.html#torch.nn.NLLLoss for more details. warnings.warn("NLLLoss2d has been deprecated. " /usr/local/lib/python3.5/dist-packages/torch/nn/_reduction.py:49: UserWarning: size_average and reduce args will be deprecated, please use reduction='mean' instead. warnings.warn(warning.format(ret)) 08-27 20:15:43.742 Using Cross Entropy Loss /usr/local/lib/python3.5/dist-packages/encoding/nn/syncbn.py:149: EncodingDeprecationWarning: encoding.nn.BatchNorm2d is now deprecated in favor of encoding.nn.SyncBatchNorm. .format('BatchNorm2d', SyncBatchNorm.name), EncodingDeprecationWarning) Traceback (most recent call last):

    File "train.py", line 380, in main() File "train.py", line 132, in main net = network.get_net(args, criterion) File "/data/code/GSCNN/network/init.py", line 12, in get_net criterion=criterion, trunk=args.trunk) File "/data/code/GSCNN/network/init.py", line 27, in get_model net = net_func(num_classes=num_classes, trunk=trunk, criterion=criterion) File "/data/code/GSCNN/network/gscnn.py", line 233, in init self.gate1 = gsc.GatedSpatialConv2d(32, 32) File "/data/code/GSCNN/my_functionals/GatedSpatialConv.py", line 36, in init False, _pair(0), groups, bias, 'zeros') TypeError: init() takes 11 positional arguments but 12 were given `

    I have tried my best to make sure all the necessary libraries are the right versions: absl-py (0.8.0) astor (0.8.0) certifi (2019.6.16) chardet (3.0.4) cycler (0.10.0) decorator (4.4.0) gast (0.2.2) google-pasta (0.1.7) grpcio (1.23.0) h5py (2.9.0) idna (2.8) imageio (2.5.0) joblib (0.13.2) Keras-Applications (1.0.8) Keras-Preprocessing (1.1.0) kiwisolver (1.1.0) Markdown (3.1.1) matplotlib (3.0.3) networkx (2.3) nose (1.3.7) numpy (1.17.1) opencv-python (4.1.0.25) Pillow (6.1.0) pip (9.0.1) protobuf (3.9.1) pyparsing (2.4.2) python-dateutil (2.8.0) PyWavelets (1.0.3) PyYAML (5.1.2) requests (2.22.0) scikit-image (0.15.0) scikit-learn (0.21.3) scipy (1.1.0) setuptools (20.7.0) six (1.12.0) tensorboard (1.14.0) tensorboardX (1.8) tensorflow (1.14.0) tensorflow-estimator (1.14.0) termcolor (1.1.0) torch (1.0.0) torch-encoding (1.0.1) torchvision (0.2.0) tqdm (4.35.0) urllib3 (1.25.3) Werkzeug (0.15.5) wheel (0.29.0) wrapt (1.11.2)

    Do you have any suggestions on how to go about fixing this?

    Best regards, Shreyas

    opened by ShreyasSkandanS 11
  • No output images from running the evaluation? Not clear if there is a code crash or not, help please

    No output images from running the evaluation? Not clear if there is a code crash or not, help please

    Hi, I am not sure the below is an error but at the same time, looking at the train.py evaluate function, it is supposed to output "threshold" and F-Score values, so I do not think the code ran up to the end properly. I can see there is an out of memory error message before processing frames but I do not know if the memory issue was a critical error since the code continued running. The frame section is not clearly looking like an error, but at the same time it could be.

    Can you tell me if this is the expected output?

    thanks

    gscnn_train_eval_run_output.txt

    opened by Tetsujinfr 5
  • Unable to train due to CUDA out of memory error in Google Colab with ultra low resolution pics

    Unable to train due to CUDA out of memory error in Google Colab with ultra low resolution pics

    Hi, thanks for the repo. However, I am not able to run my training on the cityscapes dataset. I have around 50 images for training and about 10 for validation and testing each. I have reduced the image resolution to 128x128 and still, it gives the CUDA out of memory error. I am running this on Google Colab which has 12 GB of GPU memory. Can you tell me what I should do to be able to run this model? Any changes that have to be tweaked? @shubhaminnani @tovacinni @varunjampani @davidjesusacu @ShreyasSkandanS

    opened by sainatarajan 4
  • PyTorch (<= 1.0.0 ) ?

    PyTorch (<= 1.0.0 ) ?

    In the install instructions you mention PyTorch (<= 1.0.0 ). I have pytorch 1.1, so does it means it is going to fail for sure or that you did not test with version above 1.0? If the former, is there a reason why such a recent paper/code does not run on pytorch version beyond 1.0? Thanks.

    opened by Tetsujinfr 4
  • Unfair Comparison in your paper

    Unfair Comparison in your paper

    After reading your paper and discussion, we have few questions.

    1. In the leaderboard, we can see that you use Mapillary data. However, In the paper of table 6. You compared TKCN and AAF-PSP which didn't use Mapillay data. It is obviously unfair. So what is real result without Maypiilary data and only use fine-data on Cityscapes test set ?
    2. Also we didn't find your claim in using Mapillary data in your paper why didn't mention it?
    3. In the table 3, Why mIoU is so low when use your ResNet101 backbone according other repo. ResNet101 based deeplabv3+ should be 78+. Repo: https://github.com/speedinghzl/pytorch-segmentation-toolbox
    opened by LarryBrid 4
  • Question about paper.

    Question about paper.

    Thanks for your share.

    Several questions:

    1. Does Eq.(6) miss a minus sign?
    2. How to obtain the gradient of an image for the input of the shape stream? soble?
    3. The regular steam outputs multi-scale feat-maps. How to obtain the attention maps at a resolution of HxW always?
    opened by lc82111 4
  • ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1])

    ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1])

    ValueError: Caught ValueError in replica 0 on device 0. Original Traceback (most recent call last): File "/home/renshasha/anaconda3/envs/aaa/lib/python3.7/site-packages/torch/nn/parallel/parallel_apply.py", line 60, in _worker output = module(*input, **kwargs) File "/home/renshasha/anaconda3/envs/aaa/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/home/renshasha/GSCNN-master/network/gscnn.py", line 315, in forward x = self.aspp(m7, acts) File "/home/renshasha/anaconda3/envs/aaa/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/home/renshasha/GSCNN-master/network/gscnn.py", line 167, in forward img_features = self.img_conv(img_features) File "/home/renshasha/anaconda3/envs/aaa/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/home/renshasha/anaconda3/envs/aaa/lib/python3.7/site-packages/torch/nn/modules/container.py", line 92, in forward input = module(input) File "/home/renshasha/anaconda3/envs/aaa/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/home/renshasha/anaconda3/envs/aaa/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 81, in forward exponential_average_factor, self.eps) File "/home/renshasha/anaconda3/envs/aaa/lib/python3.7/site-packages/torch/nn/functional.py", line 1652, in batch_norm raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size)) ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1])

    opened by renmmmmmm 3
  • Unused feature in forward pass?

    Unused feature in forward pass?

    I'm just reading the paper and looking at the code to follow along. In doing so I've gotten a bit confused because there seems to be an extra shape feature map in the code. In networks/gscnn.py on line 274 we have

    s1 = F.interpolate(self.dsn1(m1), x_size[2:], mode='bilinear', align_corners=True)
    

    but this is never output or used. Following the paper I would expect this to be the input to the self.res1 unit. However, this is not the case. What is actually put through that is

    m1f = F.interpolate(m1, x_size[2:], mode='bilinear', align_corners=True)
    cs = self.res1(m1f)
    

    Something is off here as we calculate s1 but do nothing with it. My question is, should s1 replace m1f or should it just be deleted?

    opened by benDavidson6 3
  • some problems about training

    some problems about training

    When I run 'python train.py --evaluate --snapshot checkpoints/best_cityscapes_checkpoint.pth',CUDA out of memory. image My GPU is 11GB of memory,How can I solve this problem,thx.

    opened by buzhiqimeiliuqiangdong 3
  • Loss implementation seems different than equation (4) in the paper.

    Loss implementation seems different than equation (4) in the paper.

    Looks like the loss implementation does not apply argmax to the semantic segmentation logits, right? But in the paper, equation (4) applies argmax before ConvTri and Gradient computation, right? Which one is the one used to produce the experimental results?

    Thank you, Hai

    opened by SHMCU 2
  • How to load wide resnet pretrained model from IMGNET

    How to load wide resnet pretrained model from IMGNET

    Thank for your great work and share your code,but i have same question,i can't finde the code load wide resnet pretraned model from ImageNet.Can anyone help?thank you.

    opened by GitHubLiaoYong 2
  • ModuleNotFoundError: No module named 'encoding'

    ModuleNotFoundError: No module named 'encoding'

    When I run 'python train.py --evaluate --snapshot checkpoints/best_cityscapes_checkpoint.pth', the bug occurs as:

    Traceback (most recent call last): File "train.py", line 381, in main() File "train.py", line 128, in main assert_and_infer_cfg(args) File "E:\Program Files\Anaconda3\envs\newName\E20220227\GSCNN\config.py", line 86, in assert_and_infer_cfg import encoding ModuleNotFoundError: No module named 'encoding'

    Then I try to install 'encoding' or search the module 'encoding' in google, but I found nothing. Why does this bug occur? And, how can I settle this problem?

    opened by xjfeng950418 1
  • ImportError: No module named 'enclib_cpu'

    ImportError: No module named 'enclib_cpu'

    Hi, I met a package bug when trying to evaluate the method by 'python train.py --evaluate --snapshot checkpoints/best_cityscapes_checkpoint.pth'

    The bug is : Traceback (most recent call last): File "train.py", line 380, in main() File "train.py", line 127, in main assert_and_infer_cfg(args) File "C:\Users\asd\Desktop\GSCNN-master\config.py", line 86, in assert_and_infer_cfg import encoding File "D:\anconda3\envs\GSCNN0415\lib\site-packages\encoding_init_.py", line 13, in from . import nn, functions, parallel, utils, models, datasets, transforms File "D:\anconda3\envs\GSCNN0415\lib\site-packages\encoding\nn_init_.py", line 12, in from .encoding import * File "D:\anconda3\envs\GSCNN0415\lib\site-packages\encoding\nn\encoding.py", line 18, in from ..functions import scaled_l2, aggregate, pairwise_cosine File "D:\anconda3\envs\GSCNN0415\lib\site-packages\encoding\functions_init_.py", line 2, in from .encoding import * File "D:\anconda3\envs\GSCNN0415\lib\site-packages\encoding\functions\encoding.py", line 14, in from .. import lib File "D:\anconda3\envs\GSCNN0415\lib\site-packages\encoding\lib_init_.py", line 15, in ], build_directory=cpu_path, verbose=False) File "D:\anconda3\envs\GSCNN0415\lib\site-packages\torch\utils\cpp_extension.py", line 644, in load is_python_module) File "D:\anconda3\envs\GSCNN0415\lib\site-packages\torch\utils\cpp_extension.py", line 824, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File "D:\anconda3\envs\GSCNN0415\lib\site-packages\torch\utils\cpp_extension.py", line 967, in _import_module_from_library file, path, description = imp.find_module(module_name, [path]) File "D:\anconda3\envs\GSCNN0415\lib\imp.py", line 297, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named 'enclib_cpu'

    It seems the unmatched packages in my conda env: pytorch 1.1.0 python 3.6.13 torch-encoding 1.0.1 torchvision 0.3.0

    So, is the torch encoding unmatched? Could you tell me how to fix it. Thank you!

    opened by yyt111222 0
  • the computer crashed und rebooted after training for a while

    the computer crashed und rebooted after training for a while

    hi, guys, i'm recently using GSCNN for traning my own dataset. I modifed some py files related with reading dataset and ran the training successfully. But computer always crashed and rebooted after training for a while. BTW i used two gpu gtx2080Ti for training. Do you guys have same problem and how to fix this?

    opened by lucafei 1
  • gate about reset

    gate about reset

    GSCNN is a novel idea. However the code is based on wide-resnet. I want to use resnet backbone, Where to get gate from resnet? And the first conv is 7*7 stide 2, where to begin for shape stream.

    image

    opened by wuyefeilin 0
Shape-aware Semi-supervised 3D Semantic Segmentation for Medical Images

SASSnet Code for paper: Shape-aware Semi-supervised 3D Semantic Segmentation for Medical Images(MICCAI 2020) Our code is origin from UA-MT You can fin

klein 125 Jan 3, 2023
PyTorch implementation of ShapeConv: Shape-aware Convolutional Layer for RGB-D Indoor Semantic Segmentation.

Shape-aware Convolutional Layer (ShapeConv) PyTorch implementation of ShapeConv: Shape-aware Convolutional Layer for RGB-D Indoor Semantic Segmentatio

Hanchao Leng 82 Dec 29, 2022
Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation)

Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation) Download Synthia dataset The model uses

null 32 Sep 21, 2022
Adaptive Pyramid Context Network for Semantic Segmentation (APCNet CVPR'2019)

Adaptive Pyramid Context Network for Semantic Segmentation (APCNet CVPR'2019) Introduction Official implementation of Adaptive Pyramid Context Network

null 21 Nov 9, 2022
NFT-Price-Prediction-CNN - Using visual feature extraction, prices of NFTs are predicted via CNN (Alexnet and Resnet) architectures.

NFT-Price-Prediction-CNN - Using visual feature extraction, prices of NFTs are predicted via CNN (Alexnet and Resnet) architectures.

null 5 Nov 3, 2022
《A-CNN: Annularly Convolutional Neural Networks on Point Clouds》(2019)

A-CNN: Annularly Convolutional Neural Networks on Point Clouds Created by Artem Komarichev, Zichun Zhong, Jing Hua from Department of Computer Science

Artёm Komarichev 44 Feb 24, 2022
A PyTorch Implementation of Gated Graph Sequence Neural Networks (GGNN)

A PyTorch Implementation of GGNN This is a PyTorch implementation of the Gated Graph Sequence Neural Networks (GGNN) as described in the paper Gated G

Ching-Yao Chuang 427 Dec 13, 2022
Source Code for our paper: Understand me, if you refer to Aspect Knowledge: Knowledge-aware Gated Recurrent Memory Network

KaGRMN-DSG_ABSA This repository contains the PyTorch source Code for our paper: Understand me, if you refer to Aspect Knowledge: Knowledge-aware Gated

XingBowen 4 May 20, 2022
A PyTorch Implementation of Gated Graph Sequence Neural Networks (GGNN)

A PyTorch Implementation of GGNN This is a PyTorch implementation of the Gated Graph Sequence Neural Networks (GGNN) as described in the paper Gated G

Ching-Yao Chuang 427 Dec 13, 2022
Code for ICCV 2021 paper: ARAPReg: An As-Rigid-As Possible Regularization Loss for Learning Deformable Shape Generators..

ARAPReg Code for ICCV 2021 paper: ARAPReg: An As-Rigid-As Possible Regularization Loss for Learning Deformable Shape Generators.. Installation The cod

Bo Sun 132 Nov 28, 2022
[ICCV 2021] Encoder-decoder with Multi-level Attention for 3D Human Shape and Pose Estimation

MAED: Encoder-decoder with Multi-level Attention for 3D Human Shape and Pose Estimation Getting Started Our codes are implemented and tested with pyth

ZiNiU WaN 176 Dec 15, 2022
Code for 'Single Image 3D Shape Retrieval via Cross-Modal Instance and Category Contrastive Learning', ICCV 2021

CMIC-Retrieval Code for Single Image 3D Shape Retrieval via Cross-Modal Instance and Category Contrastive Learning. ICCV 2021. Introduction In this wo

null 42 Nov 17, 2022
A-SDF: Learning Disentangled Signed Distance Functions for Articulated Shape Representation (ICCV 2021)

A-SDF: Learning Disentangled Signed Distance Functions for Articulated Shape Representation (ICCV 2021) This repository contains the official implemen

null 81 Dec 14, 2022
An official implementation of "Exploiting a Joint Embedding Space for Generalized Zero-Shot Semantic Segmentation" (ICCV 2021) in PyTorch.

Exploiting a Joint Embedding Space for Generalized Zero-Shot Semantic Segmentation This is an official implementation of the paper "Exploiting a Joint

CV Lab @ Yonsei University 35 Oct 26, 2022
Code for the ICCV 2021 Workshop paper: A Unified Efficient Pyramid Transformer for Semantic Segmentation.

Unified-EPT Code for the ICCV 2021 Workshop paper: A Unified Efficient Pyramid Transformer for Semantic Segmentation. Installation Linux, CUDA>=10.0,

null 29 Aug 23, 2022
[ICCV 2021] A Simple Baseline for Semi-supervised Semantic Segmentation with Strong Data Augmentation

[ICCV 2021] A Simple Baseline for Semi-supervised Semantic Segmentation with Strong Data Augmentation

CodingMan 45 Dec 12, 2022
《Deep Single Portrait Image Relighting》(ICCV 2019)

Ratio Image Based Rendering for Deep Single-Image Portrait Relighting [Project Page] This is part of the Deep Portrait Relighting project. If you find

null 62 Dec 21, 2022
This Repo is the official CUDA implementation of ICCV 2019 Oral paper for CARAFE: Content-Aware ReAssembly of FEatures

Introduction This Repo is the official CUDA implementation of ICCV 2019 Oral paper for CARAFE: Content-Aware ReAssembly of FEatures. @inproceedings{Wa

Jiaqi Wang 42 Jan 7, 2023
A Fast and Accurate One-Stage Approach to Visual Grounding, ICCV 2019 (Oral)

One-Stage Visual Grounding ***** New: Our recent work on One-stage VG is available at ReSC.***** A Fast and Accurate One-Stage Approach to Visual Grou

Zhengyuan Yang 118 Dec 5, 2022