Skip to content

This repository is a fork of BVLC/caffe and includes the upsample, bn, dense_image_data and softmax_with_loss (with class weighting) layers of SegNet with cuDNN version 7 acceleration.

License

navganti/caffe-segnet-cudnn7

 
 

Repository files navigation

Caffe SegNet cuDNN7

This is a modified version of Caffe which supports the SegNet architecture.

Alex Kendall's original caffe-segnet repository can be found here. For a more detailed introduction to this software please see the tutorial here.

Since the original caffe-segnet supports just cuDNN v2, which is not supported for Pascal based GPUs, Timo Sämann was able to decrease the inference time by 25 % to 35 % with caffe-segnet-cudnn5 using Titan X Pascal. This repository contains the changes required to run using cudNN7, however no calculation of speedup was performed.

A number of different weights can be found in the SegNet Model Zoo. It is recommended to use Timo Sämann's weights (trained on CityScapes) for semantic segmenation of traffic scenes.

If you like to speed up SegNet even further, you can run the BN-absorber.py script. It merges the batch normalization layer into the convolutional layer by modifying its weights and biases. In doing so, it is possible to accelerate it by around 30 %. Please find BN-absorber.py in the script folder.

If you like to use SegNet with C++, the test_segmentation.cpp might be helpful. https://github.com/navganti/SegNet/blob/master/scripts/example/test_segmentation.cpp

Installation

Ensure you have CUDA and cudNN installed. This has only been tested up to CUDA v9.0.

To install all depedencies, follow the instructions located at the top of the Ubuntu 16.04 Installation Guide. This installation guide goes on to discuss installation using the Makefile, which is recommended for Python users. If you with to use Caffe with C++, jump ahead to here.

Makefile

This method is recommended if you wish to use Caffe with Python! Make sure to add the caffe-segnet-cudnn7/python folder to your PYTHONPATH. Follow the remaining instructions from the Ubuntu 16.04 Installation Guide.

Some of the necessary changes to the Makefile have already been made, however, the above guide does provide a good reference for installation dependencies and build steps.

Some tips for modifying the Makefile: - If you are using ROS and OpenCV, the location of the OpenCV (as of Ubuntu 16.04 and ROS Kinetic /opt/ros/kinetic/include/opencv-3.3.1-dev and /opt/ros/kinetic/lib/x86_64-linux-gnu) needs to be appended to INCLUDE_DIRS and LIBRARY_DIRS

CMake

This method is recommended if you wish to use Caffe with C++!.

To install Caffe using the community-created CMake file, perform the following:

Note: This will install Caffe to /usr/local. If you wish to install it elsewhere, set the CMAKE_INSTALL_PREFIX, but ensure that any project using it will be able to find it.

mkdir cmake_build
cd cmake_build
cmake ..
make
make runtest
sudo make install

The CMake file currently does not build the Python layer, but this can be modified inside the CMakeLists file. I have not tested this, personally.

To use caffe-segnet-cudnn7 in a CMake project, you can now add the following lines to your project's CMakeLists.txt:

project(foo)

find_package(Caffe REQUIRED)
include_directories(${Caffe_INCLUDE_DIRS})

add_executable(foo main.cpp)
target_link_libraries(foo ${Caffe_LIBRARIES})

Publications

If you use this software in your research, please cite:

Alex Kendall, Vijay Badrinarayanan and Roberto Cipolla "Bayesian SegNet: Model Uncertainty in Deep Convolutional Encoder-Decoder Architectures for Scene Understanding." arXiv preprint arXiv:1511.02680, 2015. PDF.

Vijay Badrinarayanan, Alex Kendall and Roberto Cipolla "SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation." PAMI, 2017. PDF.

License

This extension to the Caffe library is released under a creative commons license which allows for personal and research use only. For a commercial license please contact the authors. You can view a license summary here: http://creativecommons.org/licenses/by-nc/4.0/

About

This repository is a fork of BVLC/caffe and includes the upsample, bn, dense_image_data and softmax_with_loss (with class weighting) layers of SegNet with cuDNN version 7 acceleration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 80.3%
  • Python 8.9%
  • Cuda 6.0%
  • CMake 2.7%
  • MATLAB 0.9%
  • Makefile 0.7%
  • Other 0.5%