All Projects → arslan-chaudhry → dcsp_segmentation

arslan-chaudhry / dcsp_segmentation

Licence: MIT license
No description or website provided.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to dcsp segmentation

WSCNNTDSaliency
[BMVC17] Weakly Supervised Saliency Detection with A Category-Driven Map Generator
Stars: ✭ 19 (-44.12%)
Mutual labels:  weakly-supervised-learning, saliency
Sparse Structured Attention
Sparse and structured neural attention mechanisms
Stars: ✭ 198 (+482.35%)
Mutual labels:  segmentation, attention-mechanism
GuidedLabelling
Exploiting Saliency for Object Segmentation from Image Level Labels, CVPR'17
Stars: ✭ 35 (+2.94%)
Mutual labels:  segmentation, saliency
Linear-Attention-Mechanism
Attention mechanism
Stars: ✭ 27 (-20.59%)
Mutual labels:  segmentation, attention-mechanism
Pytorch Cnn Visualizations
Pytorch implementation of convolutional neural network visualization techniques
Stars: ✭ 6,167 (+18038.24%)
Mutual labels:  segmentation, saliency
AttentionGatedVNet3D
Attention Gated VNet3D Model for KiTS19——2019 Kidney Tumor Segmentation Challenge
Stars: ✭ 35 (+2.94%)
Mutual labels:  segmentation, attention-mechanism
3HAN
An original implementation of "3HAN: A Deep Neural Network for Fake News Detection" (ICONIP 2017)
Stars: ✭ 29 (-14.71%)
Mutual labels:  attention-mechanism
VNet
Prostate MR Image Segmentation 2012
Stars: ✭ 54 (+58.82%)
Mutual labels:  segmentation
DeepSegmentor
Sequence Segmentation using Joint RNN and Structured Prediction Models (ICASSP 2017)
Stars: ✭ 17 (-50%)
Mutual labels:  segmentation
nicMSlesions
Easy multiple sclerosis white matter lesion segmentation using convolutional deep neural networks.
Stars: ✭ 33 (-2.94%)
Mutual labels:  segmentation
pcan
Prototypical Cross-Attention Networks for Multiple Object Tracking and Segmentation, NeurIPS 2021 Spotlight
Stars: ✭ 294 (+764.71%)
Mutual labels:  segmentation
halonet-pytorch
Implementation of the 😇 Attention layer from the paper, Scaling Local Self-Attention For Parameter Efficient Visual Backbones
Stars: ✭ 181 (+432.35%)
Mutual labels:  attention-mechanism
mmrazor
OpenMMLab Model Compression Toolbox and Benchmark.
Stars: ✭ 644 (+1794.12%)
Mutual labels:  segmentation
ANTsR
Advanced Normalization Tools in R
Stars: ✭ 101 (+197.06%)
Mutual labels:  segmentation
hair-dye
Neural Network for Dying Hair💈
Stars: ✭ 45 (+32.35%)
Mutual labels:  segmentation
domain-attention
codes for paper "Domain Attention Model for Multi-Domain Sentiment Classification"
Stars: ✭ 22 (-35.29%)
Mutual labels:  attention-mechanism
ML IDCard Segmentation-TF-Keras
Machine Learning Project to identify an ID Card on an image
Stars: ✭ 38 (+11.76%)
Mutual labels:  segmentation
abcnn pytorch
Implementation of ABCNN(Attention-Based Convolutional Neural Network) on Pytorch
Stars: ✭ 35 (+2.94%)
Mutual labels:  attention-mechanism
Multigrid-Neural-Architectures
Multigrid Neural Architecture
Stars: ✭ 28 (-17.65%)
Mutual labels:  attention-mechanism
color-pop
🌈 Automatic Color Pop effect on any image inspired by Google Photos
Stars: ✭ 21 (-38.24%)
Mutual labels:  segmentation

DCSP: Discovering Class Specific Pixels for Weakly Supervised Semantic Segmentation

This is the implementation of the DCSP paper in tensorflow. The network architecture is inspired from the DeepLab-v2 model, and the tensorflow reimplementation of the DeepLab-v2 is used.

When using this code, please cite our paper:

@article{chaudhry_dcsp_2017,
  title={Discovering Class-Specific Pixels for Weakly-Supervised Semantic Segmentation},
  author={Arslan Chaudhry and Puneet K. Dokania and Philip H. S. Torr},
  journal={British Machine Vision Conference (BMVC)},
  year={2017}
}

Model Description

Please refer to our paper for the full details of our model. The attention and segmentation models are based on DeepLab-v2 with an additional convolutional layer to obtain fully convolutional attention maps. For saliency cues, we used DHSNet as an off-the-shelf saliency detector. One can use saliency detector of one's choice. Please cite the respective work when using their code. We use our Hierarchical Saliency algorithm to improve the saliency maps (refer to our paper for details). The code in this repository assumes that saliency maps have already been obtained off-line prior to running the scripts in this repository.

Requirements

TensorFlow needs to be installed before running the scripts. TensorFlow v1.1.0 is supported.

To install the required python packages (except TensorFlow), run

pip install -r requirements.txt

or for a local installation

pip install -user -r requirements.txt

Initialization Models

The initialization and pretrained models are provided here. The model uses the ImageNet initialization of ResNet-101, except for the last fc* layers where the weights are initialized by the gaussian with 0 mean and 0.01 standard deviation, and biases with 0.

One can use the initialization model provided above or can convert the vanilla .caffemodel of ResNet-101. To convert the initialization model from the caffemodel, download the appropriate .caffemodel file, and install Caffe to TensorFlow dependencies. The Caffe model definition is provided in misc/deploy.prototxt. To extract weights from .caffemodel, run the following:

python convert.py /path/to/deploy/prototxt --caffemodel /path/to/caffemodel --data-output-path /where/to/save/numpy/weights

As a result of running the command above, the model weights will be stored in /where/to/save/numpy/weights. To convert them to the native TensorFlow format (.ckpt), simply execute:

python npy2ckpt.py /where/to/save/numpy/weights --save-dir=/where/to/save/ckpt/weights

Dataset and Training

To train the network, one can use the augmented PASCAL VOC 2012 dataset with 10582 images for training and 1449 images for validation. We do not make use of pixel-level annotations of the training/ validation sets and only use the image tags.

Prepare the dataset by extracting the JPEG images and image tags from the PASCAL_VOC2012 dataset in a directory. Please consult the list dataset/train_labels_only.txt in the repository for the names of the directories and corresponding files. For ease of use, extracted image tags are provided here. Save the saliency masks (in the Saliency folder) at the same level where JPEGImages and ImageTags are stored. Please see the list dataset/train_attn_sal_labels.txt in the repository for reference. Note that we have used DHSNet to generate saliency masks. A sample gen_saliency_voc.py file which uses Hierarchical Saliency algorithm to generate improved saliency masks is added in this repository. Add this file in the Caffe code of the DHSNet to generate saliency masks.

Once the files are extracted as per the lists described above, one can start training the dcsp model. dcsp.py is the main script which trains both the attention and segmentation model. To train the model, run the dcsp.py script with the appropriate command-line options. To see the documentation on each of the training settings, run the dcsp.py script with the --help flag:

python dcsp.py --help

One example run of the training script is shown below:

python dcsp.py --data-dir /home/mac/Downloads/DataSets/ --classfc-data-list ./dataset/train_labels_only.txt --segment-data-list ./dataset/train_attn_sal_labels.txt --classfc-steps 30000 --adapt-after 10000 --restore-from /home/mac/Downloads/resnet_pretrained_classification/model.ckpt --attn-snapshot-dir ./snapshots_attn_network --snapshot-dir ./snapshots_segmentation_network

Once the training script exits, the segmentation model is stored in the directory pointed by --snapshot-dir option.

Evaluation

To evaluate the model, run the evaluate.py script with appropriate command line options. The documentation on each of the evaluation option can be obtained by running:

python evaluate.py --help

One example run of the training script is shown below:

python evaluate.py --data-dir ~/Downloads/DataSets/PASCAL_VOC_Aug/ --data-list ./dataset/val.txt --num-steps 1449 --restore-from ./snapshots_segmentation_network/model.ckpt-20000

The CRF post-processing is embedded in the evaluation script. To turn-off the CRF post-processing comment out the lines number 98, 99 from the evaluate.py script. With CRF post-processing the model gives the mIOU of 60.8% on PASCAL VOC val set.

Evaluating on PASCAL Server

A training script test_voc.py is provided that allows one to generate segmentation mask in a directory, that can latter be uploaded to the PASCAL VOC evaluation/ test server. Run the test_voc.py script with appropriate options to generate the segmentation masks in a directory. The documentation on each of the option can be obtained by running:

python test_voc.py --help

On the test set of PASCAL VOC the model achieves the mIOU of 61.9%

Questions/ Bugs

  • For questions, please contact the author Arslan Chaudhry ([email protected]).
  • Please open the bugs against this repository. Any comment/ improvement would be highly appreciated.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].