Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2f869e7
clarify draw_net.py usage: net prototxt, not caffemodel
shelhamer Jan 25, 2015
61c63f6
[docs] ask install + hardware questions on caffe-users
shelhamer Jan 25, 2015
4cc8195
[docs] send API link to class list
shelhamer Jan 29, 2015
1f7c3de
[docs] add check mode hint to CPU-only mode error
shelhamer Jan 29, 2015
8b96472
Brief explanation of SLICE layer's attributes
boechat107 Jan 30, 2015
75d0e16
lint 1f7c3de
shelhamer Jan 30, 2015
e3c895b
Merge pull request #1817 from boechat107/patch-1
shelhamer Jan 30, 2015
1e0d49a
Correct 'epochs' to 'iterations'
bamos Feb 16, 2015
3e9b050
Merge pull request #1879 from bamos/patch-1
sguada Feb 16, 2015
f998127
Merge pull request #1849 from BVLC/next
shelhamer Feb 20, 2015
af01b9c
Updated the path for get_ilsvrc_aux.sh to match what is found in the …
Feb 20, 2015
5ee85b7
Merge pull request #1914 from eerwitt/master
shelhamer Feb 20, 2015
eabbccd
[build] fix dynamic linking of tools
shelhamer Feb 20, 2015
682d9da
Merge pull request #1921 from shelhamer/fix-tool-linking
shelhamer Feb 20, 2015
5a26333
check caffe tool runs in runtest
shelhamer Feb 21, 2015
a1e951d
ignore pycharm files
Feb 22, 2015
fca05c3
set proper CMAKE_INSTALL_RPATH for _caffe.so and tools
Feb 22, 2015
645aa03
fixed bug in install-tree: _caffe.so installed by install(TARGET ...)…
Feb 22, 2015
5e06d16
minor cmake sumamry log fix
Feb 22, 2015
569ae01
cpp_lint.py fails silently with Python3 (which is the default on some…
jsupancic Feb 22, 2015
cb1f4d6
Merge pull request #1939 from Nerei/bugfix/install_rpath_for_pycaffe
shelhamer Feb 22, 2015
845f9ea
APPLE was misspelled. in Line 27
spmallick Feb 24, 2015
486360d
Merge pull request #1948 from spmallick/patch-1
longjon Feb 24, 2015
c091197
Merge pull request #1941 from jsupancic/cpp_lint_python2
longjon Feb 24, 2015
360dbfd
Merge pull request #1926 from shelhamer/test-caffe-tool
longjon Feb 24, 2015
54037d3
Making python3 work with cmake and the new python wrapper
philkr Feb 17, 2015
b915f9d
Merge pull request #1923 from philkr/python3_master
longjon Feb 24, 2015
2cf5089
Decoding the datum before feeding it into the reshaping data layer
philkr Feb 25, 2015
4a3887a
fixed matcaffe printout to specify num of args (now including train/t…
forresti Feb 25, 2015
d2beb8a
Replaced illegal tab in Makefile with spaces.
gustavla Feb 25, 2015
1377e1b
Makefile fix for OS X 10.10
sergeyk Feb 25, 2015
3a1195a
Merge pull request #1961 from sergeyk/master
shelhamer Feb 25, 2015
b9aa166
Merge pull request #1960 from gustavla/makefile_fix
longjon Feb 25, 2015
25cdd35
Small fix (visualization) on SLICE layer's documentation
boechat107 Feb 25, 2015
a677076
Merge pull request #1955 from philkr/reshaping_encoded
shelhamer Feb 26, 2015
4fba3da
Merge pull request #1999 from boechat107/patch-2
longjon Feb 27, 2015
1dcfc3c
share columnation buffers for convolution to save memory
shelhamer Oct 16, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
# QtCreator files
*.user

# PyCharm files
.idea

# OSX dir files
.DS_Store

Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ caffe_option(CPU_ONLY "Build Caffe wihtout CUDA support" OFF) # TODO: rename to
caffe_option(USE_CUDNN "Build Caffe with cuDNN libary support" ON IF NOT CPU_ONLY)
caffe_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
caffe_option(BUILD_python "Build Python wrapper" ON)
set(python_version "2" CACHE STRING "Specify which python version to use")
caffe_option(BUILD_matlab "Build Matlab wrapper" OFF IF UNIX OR APPLE)
caffe_option(BUILD_docs "Build documentation" ON IF UNIX OR APPLE)

# ---[ Dependencies
include(cmake/Dependencies.cmake)

# ---[ Flags
if(UNIX OR APLE)
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
endif()

Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ ifneq (,$(findstring clang++,$(CXX)))
else ifneq (,$(findstring g++,$(CXX)))
STATIC_LINK_COMMAND := -Wl,--whole-archive $(STATIC_NAME) -Wl,--no-whole-archive
else
$(error Cannot static link with the $(CXX) compiler.)
# The following line must not be indented with a tab, since we are not inside a target
$(error Cannot static link with the $(CXX) compiler)
endif

# Debugging
Expand Down Expand Up @@ -319,7 +320,7 @@ else
# 10.10 has accelerate while 10.9 has veclib
XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep -o 'version: 6')
ifneq (,$(findstring version: 6,$(XCODE_CLT_VER)))
BLAS_INCLUDE ?= /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
LDFLAGS += -framework Accelerate
else
BLAS_INCLUDE ?= /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/
Expand Down Expand Up @@ -450,6 +451,7 @@ $(MAT$(PROJECT)_SO): $(MAT$(PROJECT)_SRC) $(STATIC_NAME)
CXXLIBS="\$$CXXLIBS $(STATIC_LINK_COMMAND) $(LDFLAGS)" -output $@

runtest: $(TEST_ALL_BIN)
$(TOOL_BUILD_DIR)/caffe
$(TEST_ALL_BIN) $(TEST_GPUID) --gtest_shuffle $(TEST_FILTER)

pytest: py
Expand Down Expand Up @@ -537,7 +539,12 @@ $(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR)
@ $(RM) $@
@ ln -s $(abspath $<) $@

$(TOOL_BINS) $(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME)
$(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME)
@ echo CXX/LD -o $@
$(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(PROJECT) $(LDFLAGS) \
-Wl,-rpath,$(ORIGIN)/../lib

$(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME)
@ echo CXX/LD -o $@
$(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(PROJECT) $(LDFLAGS) \
-Wl,-rpath,$(ORIGIN)/../../lib
Expand Down
39 changes: 33 additions & 6 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,39 @@ endif()

# ---[ Python
if(BUILD_python)
# disable Python 3 search
find_package(PythonInterp 2.7)
find_package(PythonLibs 2.7)
find_package(NumPy 1.7.1)
find_package(Boost 1.46 COMPONENTS python)

if(NOT "${python_version}" VERSION_LESS "3.0.0")
# use python3
find_package(PythonInterp 3.0)
find_package(PythonLibs 3.0)
find_package(NumPy 1.7.1)
# Find the matching boost python implementation
set(version ${PYTHONLIBS_VERSION_STRING})

STRING( REPLACE "." "" boost_py_version ${version} )
find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}")
set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})

while(NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND)
STRING( REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version} )
STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} )
if("${has_more_version}" STREQUAL "")
break()
endif()

STRING( REPLACE "." "" boost_py_version ${version} )
find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}")
set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})
endwhile()
if(NOT Boost_PYTHON_FOUND)
find_package(Boost 1.46 COMPONENTS python)
endif()
else()
# disable Python 3 search
find_package(PythonInterp 2.7)
find_package(PythonLibs 2.7)
find_package(NumPy 1.7.1)
find_package(Boost 1.46 COMPONENTS python)
endif()
if(PYTHONLIBS_FOUND AND NUMPY_FOUND AND Boost_PYTHON_FOUND)
set(HAVE_PYTHON TRUE)
endif()
Expand Down
5 changes: 5 additions & 0 deletions cmake/Misc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOLEAN "Use link paths for shared library rpath")
set(CMAKE_MACOSX_RPATH TRUE)

list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/lib __is_systtem_dir)
if(${__is_systtem_dir} STREQUAL -1)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
endif()

# ---[ Funny target
if(UNIX OR APPLE)
add_custom_target(symlink_to_build COMMAND "ln" "-sf" "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/build"
Expand Down
6 changes: 4 additions & 2 deletions cmake/Summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,19 @@ function(caffe_print_configuration_summary)
caffe_status(" C++ compiler : ${CMAKE_CXX_COMPILER}")
caffe_status(" Release CXX flags : ${__flags_rel}")
caffe_status(" Debug CXX flags : ${__flags_deb}")
caffe_status(" BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}")
caffe_status(" Build type : ${CMAKE_BUILD_TYPE}")
caffe_status("")
caffe_status(" BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}")
caffe_status(" BUILD_python : ${BUILD_python}")
caffe_status(" BUILD_matlab : ${BUILD_matlab}")
caffe_status(" BUILD_docs : ${BUILD_docs}")
caffe_status(" CPU_ONLY : ${CPU_ONLY}")
caffe_status("")
caffe_status("Dependencies:")
caffe_status(" BLAS : " APPLE THEN "Yes (vecLib)" ELSE "Yes (${BLAS})")
caffe_status(" Boost : Yes (ver. ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION})")
caffe_status(" glog : Yes")
caffe_status(" gflags : Yes")
caffe_status(" gflags : Yes")
caffe_status(" protobuf : " PROTOBUF_FOUND THEN "Yes (ver. ${PROTOBUF_VERSION})" ELSE "No" )
caffe_status(" lmdb : " LMDB_FOUND THEN "Yes (ver. ${LMDB_VERSION})" ELSE "No")
caffe_status(" Snappy : " SNAPPY_FOUND THEN "Yes (ver. ${Snappy_VERSION})" ELSE "No" )
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Caffe has several dependencies.

Pycaffe and Matcaffe interfaces have their own natural needs.

* For Python Caffe: `Python 2.7`, `numpy (>= 1.7)`, boost-provided `boost.python`
* For Python Caffe: `Python 2.7` or `Python 3.3+`, `numpy (>= 1.7)`, boost-provided `boost.python`
* For MATLAB Caffe: MATLAB with the `mex` compiler.

**cuDNN Caffe**: for fastest operation Caffe is accelerated by drop-in integration of [NVIDIA cuDNN](https://developer.nvidia.com/cudnn). To speed up your Caffe models, install cuDNN then uncomment the `USE_CUDNN := 1` flag in `Makefile.config` when installing Caffe. Acceleration is automatic. For now cuDNN v1 is integrated but see [PR #1731](https://github.com/BVLC/caffe/pull/1731) for v2.
Expand Down Expand Up @@ -69,7 +69,7 @@ but we suggest first installing the [Anaconda](https://store.continuum.io/cshop/

To import the `caffe` Python module after completing the installation, add the module directory to your `$PYTHONPATH` by `export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH` or the like. You should not import the module in the `caffe/python/caffe` directory!

*Caffe's Python interface works with Python 2.7. Python 3 or earlier Pythons are your own adventure.*
*Caffe's Python interface works with Python 2.7. Python 3.3+ should work out of the box without protobuf support. For protobuf support please install protobuf 3.0 alpha (https://developers.google.com/protocol-buffers/). Earlier Pythons are your own adventure.*

#### MATLAB

Expand Down
28 changes: 14 additions & 14 deletions docs/tutorial/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,20 @@ The `SLICE` layer is a utility layer that slices an input layer to multiple outp

* Sample

layers {
name: "slicer_label"
type: SLICE
bottom: "label"
## Example of label with a shape N x 3 x 1 x 1
top: "label1"
top: "label2"
top: "label3"
slice_param {
slice_dim: 1
slice_point: 1
slice_point: 2
}
}
layers {
name: "slicer_label"
type: SLICE
bottom: "label"
## Example of label with a shape N x 3 x 1 x 1
top: "label1"
top: "label2"
top: "label3"
slice_param {
slice_dim: 1
slice_point: 1
slice_point: 2
}
}

`slice_dim` indicates the target dimension and can assume only two values: 0 for num or 1 for channel; `slice_point` indicates indexes in the selected dimension (the number of indexes must be equal to the number of top blobs minus one).

Expand Down
2 changes: 1 addition & 1 deletion examples/imagenet/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ We assume that you already have downloaded the ImageNet training data and valida

You will first need to prepare some auxiliary data for training. This data can be downloaded by:

./data/get_ilsvrc_aux.sh
./data/ilsvrc12/get_ilsvrc_aux.sh

The training and validation input are described in `train.txt` and `val.txt` as text listing all the files and their labels. Note that we use a different indexing for labels than the ILSVRC devkit: we sort the synset names in their ASCII order, and then label them from 0 to 999. See `synset_words.txt` for the synset/name mapping.

Expand Down
2 changes: 1 addition & 1 deletion include/caffe/vision_layers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class BaseConvolutionLayer : public Layer<Dtype> {
int col_offset_;
int output_offset_;

Blob<Dtype> col_buffer_;
static Blob<Dtype> col_buffer_;
Blob<Dtype> bias_multiplier_;
};

Expand Down
2 changes: 1 addition & 1 deletion matlab/caffe/matcaffe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static void get_init_key(MEX_ARGS) {
static void init(MEX_ARGS) {
if (nrhs != 3) {
ostringstream error_msg;
error_msg << "Expected 2 arguments, got " << nrhs;
error_msg << "Expected 3 arguments, got " << nrhs;
mex_error(error_msg.str());
}

Expand Down
14 changes: 9 additions & 5 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(NOT HAVE_PYTHON)
endif()

include_directories(${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
file(GLOB_RECURSE python_srcs ${PROJECT_SOURCE_DIR}/python/*.cpp)
file(GLOB_RECURSE python_srcs ${CMAKE_SOURCE_DIR}/python/*.cpp)

add_library(pycaffe SHARED ${python_srcs})
target_link_libraries(pycaffe ${Caffe_LINK} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
Expand All @@ -22,9 +22,13 @@ if(UNIX OR APPLE)
endif()

# ---[ Install
file(GLOB files *.py requirements.txt)
install(FILES ${files} DESTINATION python)
install(DIRECTORY caffe DESTINATION python)
install(TARGETS pycaffe DESTINATION python/caffe)
file(GLOB files1 *.py requirements.txt)
install(FILES ${files1} DESTINATION python)

file(GLOB files2 caffe/*.py)
install(FILES ${files2} DESTINATION python/caffe)
install(TARGETS pycaffe DESTINATION python/caffe)
install(DIRECTORY caffe/imagenet caffe/proto caffe/test DESTINATION python/caffe)



4 changes: 3 additions & 1 deletion python/caffe/_caffe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ BOOST_PYTHON_MODULE(_caffe) {
bp::class_<vector<bool> >("BoolVec")
.def(bp::vector_indexing_suite<vector<bool> >());

import_array();
// boost python expects a void (missing) return value, while import_array
// returns NULL for python3. import_array1() forces a void return value.
import_array1();
}

} // namespace caffe
9 changes: 8 additions & 1 deletion python/caffe/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
from scipy.ndimage import zoom
from skimage.transform import resize

from caffe.proto import caffe_pb2
try:
# Python3 will most likely not be able to load protobuf
from caffe.proto import caffe_pb2
except:
if sys.version_info >= (3,0):
print("Failed to include caffe_pb2, things might go wrong!")
else:
raise

## proto / datum / ndarray conversion

Expand Down
5 changes: 4 additions & 1 deletion python/caffe/pycaffe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"""

from collections import OrderedDict
from itertools import izip_longest
try:
from itertools import izip_longest
except:
from itertools import zip_longest as izip_longest
import numpy as np

from ._caffe import Net, SGDSolver
Expand Down
6 changes: 3 additions & 3 deletions python/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def main(argv):
channel_swap=channel_swap)

if args.gpu:
print 'GPU mode'
print('GPU mode')

# Load numpy array (.npy), directory glob (*.jpg), or image file.
args.input_file = os.path.expanduser(args.input_file)
Expand All @@ -115,12 +115,12 @@ def main(argv):
else:
inputs = [caffe.io.load_image(args.input_file)]

print "Classifying %d inputs." % len(inputs)
print("Classifying %d inputs." % len(inputs))

# Classify.
start = time.time()
predictions = classifier.predict(inputs, not args.center_only)
print "Done in %.2f s." % (time.time() - start)
print("Done in %.2f s." % (time.time() - start))

# Save
np.save(args.output_file, predictions)
Expand Down
2 changes: 1 addition & 1 deletion python/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def main(argv):
context_pad=args.context_pad)

if args.gpu:
print 'GPU mode'
print('GPU mode')

# Load input.
t = time.time()
Expand Down
2 changes: 1 addition & 1 deletion python/draw_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main():
args = parse_args()
net = caffe_pb2.NetParameter()
text_format.Merge(open(args.input_net_proto_file).read(), net)
print 'Drawing net to %s' % args.output_image_file
print('Drawing net to %s' % args.output_image_file)
caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir)


Expand Down
2 changes: 1 addition & 1 deletion scripts/cpp_lint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2
#
# Copyright (c) 2009 Google Inc. All rights reserved.
#
Expand Down
3 changes: 3 additions & 0 deletions src/caffe/layers/base_conv_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace caffe {

template <typename Dtype>
Blob<Dtype> BaseConvolutionLayer<Dtype>::col_buffer_;

template <typename Dtype>
void BaseConvolutionLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
Expand Down
9 changes: 8 additions & 1 deletion src/caffe/layers/data_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ void DataLayer<Dtype>::InternalThreadEntry() {
// Reshape on single input batches for inputs of varying dimension.
const int batch_size = this->layer_param_.data_param().batch_size();
const int crop_size = this->layer_param_.transform_param().crop_size();
bool force_color = this->layer_param_.data_param().force_encoded_color();
if (batch_size == 1 && crop_size == 0) {
Datum datum;
datum.ParseFromString(cursor_->value());
if (datum.encoded()) {
if (force_color) {
DecodeDatum(&datum, true);
} else {
DecodeDatumNative(&datum);
}
}
this->prefetch_data_.Reshape(1, datum.channels(),
datum.height(), datum.width());
this->transformed_data_.Reshape(1, datum.channels(),
Expand All @@ -104,7 +112,6 @@ void DataLayer<Dtype>::InternalThreadEntry() {
if (this->output_labels_) {
top_label = this->prefetch_label_.mutable_cpu_data();
}
bool force_color = this->layer_param_.data_param().force_encoded_color();
for (int item_id = 0; item_id < batch_size; ++item_id) {
timer.Start();
// get a blob
Expand Down