Skip to content

Commit 9da7bcb

Browse files
committed
Merge pull request BVLC#167 from BVLC/next
So be it.
2 parents a9cce84 + 527cfab commit 9da7bcb

Some content is hidden

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

65 files changed

+2008
-1434280
lines changed

.gitignore

+27-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## General
2+
13
# Compiled Object files
24
*.slo
35
*.lo
@@ -19,25 +21,38 @@
1921
*.pb.cc
2022
*_pb2.py
2123

22-
# bin files
24+
# Compiled python
25+
*.pyc
26+
27+
# Compiled MATLAB
28+
*.mex
29+
*.mexa64
30+
*.mexmaci64
31+
32+
# build, distribute, and bins
33+
build/*
34+
distribute/*
2335
*.testbin
2436
*.bin
2537

26-
# vim swp files
38+
# Editor temporaries
2739
*.swp
28-
29-
# matlab binary
30-
*.mexa64
40+
*~
3141

3242
# IPython notebook checkpoints
3343
.ipynb_checkpoints
3444

35-
# anything under data/ unless we force include them
36-
data/*
37-
38-
# anything under distribute
39-
distribute/*
45+
## Caffe
4046

41-
# user's specified config
47+
# User's build configuration
4248
Makefile.config
43-
docs/_site
49+
50+
# Models, Data, and Examples are either
51+
# 1. reference, and not casually committed
52+
# 2. custom, and live on their own unless they're deliberated contributed
53+
models/*
54+
data/*
55+
examples/*
56+
57+
# Don't version the generated documentation
58+
docs/_site

Makefile

+22-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ TEST_SRCS := $(shell find src/$(PROJECT) -name "test_*.cpp")
2626
GTEST_SRC := src/gtest/gtest-all.cpp
2727
# TEST_HDRS are the test header files
2828
TEST_HDRS := $(shell find src/$(PROJECT) -name "test_*.hpp")
29+
# TOOL_SRCS are the source files for the tool binaries
30+
TOOL_SRCS := $(shell find tools -name "*.cpp")
2931
# EXAMPLE_SRCS are the source files for the example binaries
3032
EXAMPLE_SRCS := $(shell find examples -name "*.cpp")
3133
# PROTO_SRCS are the protocol buffer definitions
@@ -46,16 +48,18 @@ PROTO_GEN_CC := ${PROTO_SRCS:.proto=.pb.cc}
4648
PROTO_GEN_PY := ${PROTO_SRCS:.proto=_pb2.py}
4749
# The objects corresponding to the source files
4850
# These objects will be linked into the final shared library, so we
49-
# exclude the test and example objects.
51+
# exclude the tool, example, and test objects.
5052
CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o})
5153
CU_OBJS := $(addprefix $(BUILD_DIR)/, ${CU_SRCS:.cu=.cuo})
5254
PROTO_OBJS := $(addprefix $(BUILD_DIR)/, ${PROTO_GEN_CC:.cc=.o})
5355
OBJS := $(PROTO_OBJS) $(CXX_OBJS) $(CU_OBJS)
54-
# program and test objects
56+
# tool, example, and test objects
57+
TOOL_OBJS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o})
5558
EXAMPLE_OBJS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o})
5659
TEST_OBJS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o})
5760
GTEST_OBJ := $(addprefix $(BUILD_DIR)/, ${GTEST_SRC:.cpp=.o})
58-
# program and test bins
61+
# tool, example, and test bins
62+
TOOL_BINS := ${TOOL_OBJS:.o=.bin}
5963
EXAMPLE_BINS := ${EXAMPLE_OBJS:.o=.bin}
6064
TEST_BINS := ${TEST_OBJS:.o=.testbin}
6165

@@ -86,13 +90,14 @@ PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library))
8690
##############################
8791
# Define build targets
8892
##############################
89-
.PHONY: all init test clean linecount examples py mat distribute py$(PROJECT) mat$(PROJECT) proto
93+
.PHONY: all init test clean linecount tools examples py mat distribute py$(PROJECT) mat$(PROJECT) proto
9094

91-
all: init $(NAME) $(STATIC_NAME) examples
95+
all: init $(NAME) $(STATIC_NAME) tools examples
9296
@echo $(CXX_OBJS)
9397

9498
init:
9599
@ mkdir -p $(foreach obj,$(OBJS),$(dir $(obj)))
100+
@ mkdir -p $(foreach obj,$(TOOL_OBJS),$(dir $(obj)))
96101
@ mkdir -p $(foreach obj,$(EXAMPLE_OBJS),$(dir $(obj)))
97102
@ mkdir -p $(foreach obj,$(TEST_OBJS),$(dir $(obj)))
98103
@ mkdir -p $(foreach obj,$(GTEST_OBJ),$(dir $(obj)))
@@ -102,6 +107,8 @@ linecount: clean
102107

103108
test: init $(TEST_BINS)
104109

110+
tools: init $(TOOL_BINS)
111+
105112
examples: init $(EXAMPLE_BINS)
106113

107114
py$(PROJECT): py
@@ -134,6 +141,10 @@ runtest: test
134141
$(TEST_BINS): %.testbin : %.o $(GTEST_OBJ) $(STATIC_NAME) $(TEST_HDRS)
135142
$(CXX) $< $(GTEST_OBJ) $(STATIC_NAME) -o $@ $(CXXFLAGS) $(LDFLAGS) $(WARNINGS)
136143

144+
$(TOOL_BINS): %.bin : %.o $(STATIC_NAME)
145+
$(CXX) $< $(STATIC_NAME) -o $@ $(CXXFLAGS) $(LDFLAGS) $(WARNINGS)
146+
@echo
147+
137148
$(EXAMPLE_BINS): %.bin : %.o $(STATIC_NAME)
138149
$(CXX) $< $(STATIC_NAME) -o $@ $(CXXFLAGS) $(LDFLAGS) $(WARNINGS)
139150
@echo
@@ -172,6 +183,10 @@ $(BUILD_DIR)/src/$(PROJECT)/util/%.cuo: src/$(PROJECT)/util/%.cu
172183
$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -c $< -o $@
173184
@echo
174185

186+
$(BUILD_DIR)/tools/%.o: tools/%.cpp
187+
$(CXX) $< $(CXXFLAGS) -c -o $@ $(LDFLAGS)
188+
@echo
189+
175190
$(BUILD_DIR)/examples/%.o: examples/%.cpp
176191
$(CXX) $< $(CXXFLAGS) -c -o $@ $(LDFLAGS)
177192
@echo
@@ -201,8 +216,9 @@ distribute: all
201216
mkdir $(DISTRIBUTE_DIR)
202217
# add include
203218
cp -r include $(DISTRIBUTE_DIR)/
204-
# add example binaries
219+
# add tool and example binaries
205220
mkdir $(DISTRIBUTE_DIR)/bin
221+
cp $(TOOL_BINS) $(DISTRIBUTE_DIR)/bin
206222
cp $(EXAMPLE_BINS) $(DISTRIBUTE_DIR)/bin
207223
# add libraries
208224
mkdir $(DISTRIBUTE_DIR)/lib

data/cifar10/get_cifar10.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env sh
2+
# This scripts downloads the CIFAR10 (binary version) data and unzips it.
3+
4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
cd $DIR
6+
7+
echo "Downloading..."
8+
9+
wget -q http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz
10+
11+
echo "Unzipping..."
12+
13+
tar -xf cifar-10-binary.tar.gz && rm -f cifar-10-binary.tar.gz
14+
mv cifar-10-batches-bin/* . && rm -rf cifar-10-batches-bin
15+
16+
# Creation is split out because leveldb sometimes causes segfault
17+
# and needs to be re-created.
18+
19+
echo "Done."

data/create_mnist.sh

-12
This file was deleted.

data/ilsvrc12/get_ilsvrc_aux.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env sh
2+
#
3+
# N.B. This does not download the ilsvrcC12 data set, as it is gargantuan.
4+
# This script downloads the imagenet example auxiliary files including:
5+
# - the ilsvrc12 image mean, binaryproto
6+
# - synset ids and words
7+
# - the training splits with labels
8+
9+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10+
cd $DIR
11+
12+
echo "Downloading..."
13+
14+
wget -q https://www.dropbox.com/s/g5myor4y2scdv95/caffe_ilsvrc12.tar.gz
15+
16+
echo "Unzipping..."
17+
18+
tar -xf caffe_ilsvrc12.tar.gz && rm -f caffe_ilsvrc12.tar.gz
19+
20+
echo "Done."

data/get_mnist.sh data/mnist/get_mnist.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env sh
22
# This scripts downloads the mnist data and unzips it.
33

4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
cd $DIR
6+
47
echo "Downloading..."
58

69
wget -q http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz

data/train_mnist.sh

-3
This file was deleted.

docs/imagenet_pretrained.md

+9-19
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,23 @@ title: Caffe
66
Running Pretrained ImageNet
77
===========================
88

9-
[View this page as an IPython Notebook](http://nbviewer.ipython.org/url/caffe.berkeleyvision.org/imagenet_pretrained_files/imagenet_pretrained.ipynb)
10-
11-
For easier use of pretrained models, we provide a wrapper specifically written
12-
for the case of ImageNet, so one can take an image and directly compute features
13-
or predictions from them. Both Python and Matlab wrappers are provided. We will
14-
describe the use of the Python wrapper here, and the Matlab wrapper usage is
15-
very similar.
16-
17-
We assume that you have successfully compiled Caffe and set the correct
18-
`PYTHONPATH`. If not, please refer to the [installation
19-
instructions](installation.html). You will use our pre-trained imagenet model,
20-
which you can
21-
[download here](https://www.dropbox.com/s/n3jups0gr7uj0dv/caffe_reference_imagenet_model)
22-
(232.57MB). Note that this pre-trained model is licensed for academic research /
23-
non-commercial use only.
9+
[View this page as an IPython Notebook](http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/imagenet_pretrained.ipynb)
10+
11+
For easier use of pretrained models, we provide a wrapper specifically written for the case of ImageNet, so one can take an image and directly compute features or predictions from them. Both Python and Matlab wrappers are provided. We will describe the use of the Python wrapper here, and the Matlab wrapper usage is very similar.
12+
13+
We assume that you have successfully compiled Caffe and set the correct `PYTHONPATH`. If not, please refer to the [installation instructions](installation.html). You will use our pre-trained imagenet model, which you can download (232.57MB) by running `models/get_caffe_reference_imagenet_model.sh`.Note that this pre-trained model is licensed for academic research / non-commercial use only.
2414

2515
Ready? Let's start.
2616

2717

2818
from caffe import imagenet
2919
from matplotlib import pyplot
30-
20+
3121
# Set the right path to your model file, pretrained model,
3222
# and the image you would like to classify.
33-
MODEL_FILE = 'examples/imagenet_deploy.prototxt'
34-
PRETRAINED = '/home/jiayq/Downloads/caffe_reference_imagenet_model'
35-
IMAGE_FILE = '/home/jiayq/lena.png'
23+
MODEL_FILE = 'models/imagenet.prototxt'
24+
PRETRAINED = 'models/caffe_reference_imagenet_model'
25+
IMAGE_FILE = '/path/to/lena.png'
3626

3727
Loading a network is easy. imagenet.ImagenetClassifier wraps everything. In
3828
default, the classifier will crop the center and corners of an image, as well as

0 commit comments

Comments
 (0)