Skip to content

Commit 3ddb109

Browse files
committed
Initial bulk commit with the CRF-RNN code.
Caffe base code was taken from https://github.com/longjon/caffe/tree/future. Unfortunately, we were unable to directly fork from that repo and apply our patches since the two codebases have deviated too much now.
1 parent bc8edb6 commit 3ddb109

File tree

389 files changed

+92049
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

389 files changed

+92049
-2
lines changed

CONTRIBUTORS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Contributors
2+
3+
CRF-RNN specific code in this repository was written by:
4+
5+
+ Sadeep Jayasumana (sadeep.jay@gmail.com)<br/>
6+
+ Bernardino Romera-Paredes (bernardino.romeraparedes@eng.ox.ac.uk)<br/>
7+
+ Shuai Zheng (kylezheng04@gmail.com)<br/>
8+
+ Zhizhong Su (suzhizhong@baidu.com)
9+
10+
Our code uses the [Permutohedral lattice library](http://graphics.stanford.edu/papers/permutohedral/), and the [Caffe future version](https://github.com/longjon/caffe/tree/future).
11+
We also used parts of the [Dense CRF code](http://www.philkr.net/home/densecrf) while implementing this.
12+
13+
Permutohedral lattice library (BSD license) is from Andrew Adams, Jongmin Baek, Abe Davis. Fast High-Dimensional Filtering Using the
14+
Permutohedral Lattice. Eurographics 2010.
15+
DenseCRF library is from from Philipp Krahenbuhl and Vladlen Koltun. Efficient Inference in Fully Connected CRFs with Gaussian Edge Potentials.
16+
NIPS 2011.
17+
18+
Our software is built on top of the Caffe software library. Below is a copy of its CONTRIBUTORS.md file.
19+
Please note that, due to technical difficulties, we could not keep the history of the original contributors to Caffe code in our git repository.
20+
Please refer to the original [Caffe git repository](https://github.com/BVLC/caffe) for this purpose.
21+
22+
-----------------------------------------------------------------------------------------------------------------
23+
24+
Caffe is developed by a core set of BVLC members and the open-source community.
25+
26+
We thank all of our [contributors](https://github.com/BVLC/caffe/graphs/contributors)!
27+
28+
**For the detailed history of contributions** of a given file, try
29+
30+
git blame file
31+
32+
to see line-by-line credits and
33+
34+
git log --follow file
35+
36+
to see the change log even across renames and rewrites.
37+
38+
Please refer to the [acknowledgements](http://caffe.berkeleyvision.org/#acknowledgements) on the Caffe site for further details.
39+
40+
**Copyright** is held by the original contributor according to the versioning history; see LICENSE.

README.md

Lines changed: 121 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,121 @@
1-
# crfasrnn
2-
This repository contains the source code for the semantic image segmentation method described in the ICCV 2015 paper: Conditional Random Fields as Recurrent Neural Networks. http://crfasrnn.torr.vision/
1+
# CRF-RNN for Semantic Image Segmentation
2+
![sample](sample.png)
3+
4+
<b>Live demo:</b> [http://crfasrnn.torr.vision](http://crfasrnn.torr.vision)
5+
6+
This package contains code for the "CRF-RNN" semantic image segmentation method, published in the ICCV 2015 paper [Conditional Random Fields as Recurrent Neural Networks](http://www.robots.ox.ac.uk/~szheng/papers/CRFasRNN.pdf). Our software is built on top of the [Caffe](http://caffe.berkeleyvision.org/) deep learning library. The current version was developed by:
7+
8+
[Sadeep Jayasumana](http://www.robots.ox.ac.uk/~sadeep/),
9+
[Shuai Zheng](http://kylezheng.org/),
10+
[Bernardino Romera Paredes](http://romera-paredes.com/), and
11+
[Zhizhong Su](suzhizhong@baidu.com).
12+
13+
Supervisor: [Philip Torr](http://www.robots.ox.ac.uk/~tvg/)
14+
15+
Our work allows computers to recognize objects in images, what is distinctive about our work is that we also recover the 2D outline of the object.
16+
17+
Currently we have trained this model to recognize 20 classes. This software allows you to test our algorithm on your own images – have a try and see if you can fool it, if you get some good examples you can send them to us.
18+
19+
Why are we doing this? This work is part of a project to build augmented reality glasses for the partially sighted. Please read about it here: [smart-specs](http://www.va-st.com/smart-specs/).
20+
21+
For demo and more information about CRF-RNN please visit the project website <http://crfasrnn.torr.vision>.
22+
23+
If you use this code/model for your research, please consider citing the following paper:
24+
```
25+
@inproceedings{crfasrnn_ICCV2015,
26+
author = {Shuai Zheng and Sadeep Jayasumana and Bernardino Romera-Paredes and Vibhav Vineet and Zhizhong Su and Dalong Du and Chang Huang and Philip H. S. Torr},
27+
title = {Conditional Random Fields as Recurrent Neural Networks},
28+
booktitle = {International Conference on Computer Vision (ICCV)},
29+
year = {2015}
30+
}
31+
```
32+
33+
34+
#Installation Guide
35+
36+
You need to compile the modified Caffe library in this repository. Instructions for Ubuntu 14.04 are included below. You can also consult the generic [Caffe installation guide](http://caffe.berkeleyvision.org/installation.html).
37+
38+
39+
###1.1 Install dependencies
40+
#####General dependencies
41+
```
42+
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
43+
sudo apt-get install --no-install-recommends libboost-all-dev
44+
```
45+
46+
#####CUDA
47+
Install CUDA correct driver and its SDK. Download CUDA SDK from Nvidia website.
48+
49+
In Ubuntu 14.04. You need to make sure the required tools are installed. You might need to blacklist the required modules so that they do not interfere with the driver installation. You also need to uninstall your default Nvidia Driver first.
50+
```
51+
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
52+
```
53+
open /etc/modprobe.d/blacklist.conf and add:
54+
```
55+
blacklist amd76x_edac
56+
blacklist vga16fb
57+
blacklist nouveau
58+
blacklist rivafb
59+
blacklist nvidiafb
60+
blacklist rivatv
61+
```
62+
```
63+
sudo apt-get remove --purge nvidia*
64+
```
65+
66+
When you restart your PC, before loging in, try "Ctrl+Alt+F1" switch to a text-based login. Try:
67+
```
68+
sudo service lightdm stop
69+
chmod +x cuda*.run
70+
sudo ./cuda*.run
71+
```
72+
73+
#####BLAS
74+
Install ATLAS or OpenBLAS or MKL.
75+
76+
#####Python
77+
Install Anaconda Python distribution or install the default Python distribution with numpy/scipy/...
78+
79+
#####MATLAB (optional)
80+
Install MATLAB using a standard distribution.
81+
82+
###1.2 Build the custom Caffe version
83+
Set the path correctly in the Makefile.config. You can copy the Makefile.config.example to Makefile.config, as most common parts are filled already. You need to change it according to your environment.
84+
85+
After this, in Ubuntu 14.04, try:
86+
```
87+
make
88+
```
89+
90+
If there are no error messages, you can then compile and install the python and matlab wrappers:
91+
```
92+
make matcaffe
93+
```
94+
95+
```
96+
make pycaffe
97+
```
98+
99+
That's it! Enjoy our software!
100+
101+
102+
###1.3 Run the demo
103+
Matlab and Python scripts for running the demo are available in the matlab-scripts and python-scripts directories, respectively. You can choose either of them. Note that you should change the paths in the scripts according your environment.
104+
105+
# LICENSE
106+
CRF-RNN feature in Caffe is implemented for the paper:
107+
Shuai Zheng, Sadeep Jayasumana, Bernardino Romera-Paredes, Vibhav Vineet, Zhizhong Su, Dalong Du, Chang Huang, Philip H. S. Torr.
108+
Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015.
109+
110+
Shuai Zheng, Sadeep Jayasumana, Bernardino Romera-Paredes, and Philip H. S. Torr are with University of Oxford.
111+
Vibhav Vineet did this work when he was with the University of Oxford, he is now with the Stanford University.
112+
Zhizhong Su, Dalong Du, Chang Huang are with the Baidu Institute of Deep Learning (IDL).
113+
114+
CRF-RNN uses the Permutohedral lattice library, the DenseCRF library and the Caffe future version.
115+
116+
Permutohedral lattice library (BSD license) is from Andrew Adams, Jongmin Baek, Abe Davis. Fast High-Dimensional Filtering Using the
117+
Permutohedral Lattice. Eurographics 2010.
118+
DenseCRF library from Philipp Krahenbuhl and Vladlen Koltun. Efficient Inference in Fully Connected CRFs with Gaussian Edge Potentials.
119+
NIPS 2011.
120+
121+
For more information about CRF-RNN please vist the project website http://crfasrnn.torr.vision.

caffe-crfrnn/CMakeLists.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
cmake_minimum_required(VERSION 2.8.7)
2+
3+
# ---[ Caffe project
4+
project(Caffe C CXX)
5+
6+
# ---[ Using cmake scripts and modules
7+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
8+
9+
include(ExternalProject)
10+
11+
include(cmake/Utils.cmake)
12+
include(cmake/Targets.cmake)
13+
include(cmake/Misc.cmake)
14+
include(cmake/Summary.cmake)
15+
include(cmake/ConfigGen.cmake)
16+
17+
# ---[ Options
18+
caffe_option(CPU_ONLY "Build Caffe without CUDA support" OFF) # TODO: rename to USE_CUDA
19+
caffe_option(USE_CUDNN "Build Caffe with cuDNN libary support" ON IF NOT CPU_ONLY)
20+
caffe_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
21+
caffe_option(BUILD_python "Build Python wrapper" ON)
22+
set(python_version "2" CACHE STRING "Specify which python version to use")
23+
caffe_option(BUILD_matlab "Build Matlab wrapper" OFF IF UNIX OR APPLE)
24+
caffe_option(BUILD_docs "Build documentation" ON IF UNIX OR APPLE)
25+
caffe_option(BUILD_python_layer "Build the Caffe python layer" ON)
26+
27+
# ---[ Dependencies
28+
include(cmake/Dependencies.cmake)
29+
30+
# ---[ Flags
31+
if(UNIX OR APPLE)
32+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
33+
endif()
34+
35+
if(USE_libstdcpp)
36+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
37+
message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
38+
endif()
39+
40+
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE)
41+
42+
# ---[ Warnings
43+
caffe_warnings_disable(CMAKE_CXX_FLAGS -Wno-sign-compare -Wno-uninitialized)
44+
45+
# ---[ Config generation
46+
configure_file(cmake/Templates/caffe_config.h.in "${PROJECT_BINARY_DIR}/caffe_config.h")
47+
48+
# ---[ Includes
49+
set(Caffe_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
50+
include_directories(${Caffe_INCLUDE_DIR} ${PROJECT_BINARY_DIR})
51+
include_directories(BEFORE src) # This is needed for gtest.
52+
53+
# ---[ Subdirectories
54+
add_subdirectory(src/gtest)
55+
add_subdirectory(src/caffe)
56+
add_subdirectory(tools)
57+
add_subdirectory(examples)
58+
add_subdirectory(python)
59+
add_subdirectory(matlab)
60+
add_subdirectory(docs)
61+
62+
# ---[ Linter target
63+
add_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/lint.cmake)
64+
65+
# ---[ pytest target
66+
add_custom_target(pytest COMMAND python${python_version} -m unittest discover -s caffe/test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python )
67+
add_dependencies(pytest pycaffe)
68+
69+
# ---[ Configuration summary
70+
caffe_print_configuration_summary()
71+
72+
# ---[ Export configs generation
73+
caffe_generate_export_configs()
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Find the Atlas (and Lapack) libraries
2+
#
3+
# The following variables are optionally searched for defaults
4+
# Atlas_ROOT_DIR: Base directory where all Atlas components are found
5+
#
6+
# The following are set after configuration is done:
7+
# Atlas_FOUND
8+
# Atlas_INCLUDE_DIRS
9+
# Atlas_LIBRARIES
10+
# Atlas_LIBRARYRARY_DIRS
11+
12+
set(Atlas_INCLUDE_SEARCH_PATHS
13+
/usr/include/atlas
14+
/usr/include/atlas-base
15+
$ENV{Atlas_ROOT_DIR}
16+
$ENV{Atlas_ROOT_DIR}/include
17+
)
18+
19+
set(Atlas_LIB_SEARCH_PATHS
20+
/usr/lib/atlas
21+
/usr/lib/atlas-base
22+
$ENV{Atlas_ROOT_DIR}
23+
$ENV{Atlas_ROOT_DIR}/lib
24+
)
25+
26+
find_path(Atlas_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS})
27+
find_path(Atlas_CLAPACK_INCLUDE_DIR NAMES clapack.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS})
28+
find_library(Atlas_CBLAS_LIBRARY NAMES ptcblas_r ptcblas cblas_r cblas PATHS ${Atlas_LIB_SEARCH_PATHS})
29+
find_library(Atlas_BLAS_LIBRARY NAMES atlas_r atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
30+
find_library(Atlas_LAPACK_LIBRARY NAMES alapack_r alapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
31+
32+
set(LOOKED_FOR
33+
34+
Atlas_CBLAS_INCLUDE_DIR
35+
Atlas_CLAPACK_INCLUDE_DIR
36+
37+
Atlas_CBLAS_LIBRARY
38+
Atlas_BLAS_LIBRARY
39+
Atlas_LAPACK_LIBRARY
40+
)
41+
42+
include(FindPackageHandleStandardArgs)
43+
find_package_handle_standard_args(Atlas DEFAULT_MSG ${LOOKED_FOR})
44+
45+
if(ATLAS_FOUND)
46+
47+
mark_as_advanced(${LOOKED_FOR})
48+
49+
set(Atlas_INCLUDE_DIR
50+
${Atlas_CBLAS_INCLUDE_DIR}
51+
${Atlas_CLAPACK_INCLUDE_DIR}
52+
)
53+
54+
set(Atlas_LIBRARIES
55+
${Atlas_LAPACK_LIBRARY}
56+
${Atlas_CBLAS_LIBRARY}
57+
${Atlas_BLAS_LIBRARY}
58+
)
59+
60+
endif(ATLAS_FOUND)
61+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# - Try to find GFLAGS
2+
#
3+
# The following variables are optionally searched for defaults
4+
# GFLAGS_ROOT_DIR: Base directory where all GFLAGS components are found
5+
#
6+
# The following are set after configuration is done:
7+
# GFLAGS_FOUND
8+
# GFLAGS_INCLUDE_DIRS
9+
# GFLAGS_LIBRARIES
10+
# GFLAGS_LIBRARYRARY_DIRS
11+
12+
include(FindPackageHandleStandardArgs)
13+
14+
set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags")
15+
16+
# We are testing only a couple of files in the include directories
17+
if(WIN32)
18+
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
19+
PATHS ${GFLAGS_ROOT_DIR}/src/windows)
20+
else()
21+
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
22+
PATHS ${GFLAGS_ROOT_DIR})
23+
endif()
24+
25+
if(MSVC)
26+
find_library(GFLAGS_LIBRARY_RELEASE
27+
NAMES libgflags
28+
PATHS ${GFLAGS_ROOT_DIR}
29+
PATH_SUFFIXES Release)
30+
31+
find_library(GFLAGS_LIBRARY_DEBUG
32+
NAMES libgflags-debug
33+
PATHS ${GFLAGS_ROOT_DIR}
34+
PATH_SUFFIXES Debug)
35+
36+
set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG})
37+
else()
38+
find_library(GFLAGS_LIBRARY gflags)
39+
endif()
40+
41+
find_package_handle_standard_args(GFLAGS DEFAULT_MSG
42+
GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
43+
44+
45+
if(GFLAGS_FOUND)
46+
set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR})
47+
set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY})
48+
endif()
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# - Try to find Glog
2+
#
3+
# The following variables are optionally searched for defaults
4+
# GLOG_ROOT_DIR: Base directory where all GLOG components are found
5+
#
6+
# The following are set after configuration is done:
7+
# GLOG_FOUND
8+
# GLOG_INCLUDE_DIRS
9+
# GLOG_LIBRARIES
10+
# GLOG_LIBRARYRARY_DIRS
11+
12+
include(FindPackageHandleStandardArgs)
13+
14+
set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog")
15+
16+
if(WIN32)
17+
find_path(GLOG_INCLUDE_DIR glog/logging.h
18+
PATHS ${GLOG_ROOT_DIR}/src/windows)
19+
else()
20+
find_path(GLOG_INCLUDE_DIR glog/logging.h
21+
PATHS ${GLOG_ROOT_DIR})
22+
endif()
23+
24+
if(MSVC)
25+
find_library(GLOG_LIBRARY_RELEASE libglog_static
26+
PATHS ${GLOG_ROOT_DIR}
27+
PATH_SUFFIXES Release)
28+
29+
find_library(GLOG_LIBRARY_DEBUG libglog_static
30+
PATHS ${GLOG_ROOT_DIR}
31+
PATH_SUFFIXES Debug)
32+
33+
set(GLOG_LIBRARY optimized ${GLOG_LIBRARY_RELEASE} debug ${GLOG_LIBRARY_DEBUG})
34+
else()
35+
find_library(GLOG_LIBRARY glog
36+
PATHS ${GLOG_ROOT_DIR}
37+
PATH_SUFFIXES
38+
lib
39+
lib64)
40+
endif()
41+
42+
find_package_handle_standard_args(GLOG DEFAULT_MSG
43+
GLOG_INCLUDE_DIR GLOG_LIBRARY)
44+
45+
if(GLOG_FOUND)
46+
set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
47+
set(GLOG_LIBRARIES ${GLOG_LIBRARY})
48+
endif()

0 commit comments

Comments
 (0)