Skip to content

Commit bca6595

Browse files
committed
Merge pull request #142 from shelhamer/data-aux
Sort out models, data, examples, and tools
2 parents 227c0fc + f23b1f4 commit bca6595

Some content is hidden

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

54 files changed

+373
-1434278
lines changed

.gitignore

Lines changed: 27 additions & 12 deletions
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

Lines changed: 22 additions & 6 deletions
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

@@ -91,13 +95,14 @@ PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library))
9195
##############################
9296
# Define build targets
9397
##############################
94-
.PHONY: all init test clean linecount examples py mat distribute py$(PROJECT) mat$(PROJECT) proto
98+
.PHONY: all init test clean linecount tools examples py mat distribute py$(PROJECT) mat$(PROJECT) proto
9599

96-
all: init $(NAME) $(STATIC_NAME) examples
100+
all: init $(NAME) $(STATIC_NAME) tools examples
97101
@echo $(CXX_OBJS)
98102

99103
init:
100104
@ mkdir -p $(foreach obj,$(OBJS),$(dir $(obj)))
105+
@ mkdir -p $(foreach obj,$(TOOL_OBJS),$(dir $(obj)))
101106
@ mkdir -p $(foreach obj,$(EXAMPLE_OBJS),$(dir $(obj)))
102107
@ mkdir -p $(foreach obj,$(TEST_OBJS),$(dir $(obj)))
103108
@ mkdir -p $(foreach obj,$(GTEST_OBJ),$(dir $(obj)))
@@ -107,6 +112,8 @@ linecount: clean
107112

108113
test: init $(TEST_BINS)
109114

115+
tools: init $(TOOL_BINS)
116+
110117
examples: init $(EXAMPLE_BINS)
111118

112119
py$(PROJECT): py
@@ -139,6 +146,10 @@ runtest: test
139146
$(TEST_BINS): %.testbin : %.o $(GTEST_OBJ) $(STATIC_NAME) $(TEST_HDRS)
140147
$(CXX) $< $(GTEST_OBJ) $(STATIC_NAME) -o $@ $(CXXFLAGS) $(LDFLAGS) $(WARNINGS)
141148

149+
$(TOOL_BINS): %.bin : %.o $(STATIC_NAME)
150+
$(CXX) $< $(STATIC_NAME) -o $@ $(CXXFLAGS) $(LDFLAGS) $(WARNINGS)
151+
@echo
152+
142153
$(EXAMPLE_BINS): %.bin : %.o $(STATIC_NAME)
143154
$(CXX) $< $(STATIC_NAME) -o $@ $(CXXFLAGS) $(LDFLAGS) $(WARNINGS)
144155
@echo
@@ -177,6 +188,10 @@ $(BUILD_DIR)/src/$(PROJECT)/util/%.cuo: src/$(PROJECT)/util/%.cu
177188
$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -c $< -o $@
178189
@echo
179190

191+
$(BUILD_DIR)/tools/%.o: tools/%.cpp
192+
$(CXX) $< $(CXXFLAGS) -c -o $@ $(LDFLAGS)
193+
@echo
194+
180195
$(BUILD_DIR)/examples/%.o: examples/%.cpp
181196
$(CXX) $< $(CXXFLAGS) -c -o $@ $(LDFLAGS)
182197
@echo
@@ -206,8 +221,9 @@ distribute: all
206221
mkdir $(DISTRIBUTE_DIR)
207222
# add include
208223
cp -r include $(DISTRIBUTE_DIR)/
209-
# add example binaries
224+
# add tool and example binaries
210225
mkdir $(DISTRIBUTE_DIR)/bin
226+
cp $(TOOL_BINS) $(DISTRIBUTE_DIR)/bin
211227
cp $(EXAMPLE_BINS) $(DISTRIBUTE_DIR)/bin
212228
# add libraries
213229
mkdir $(DISTRIBUTE_DIR)/lib

data/cifar10/get_cifar10.sh

Lines changed: 19 additions & 0 deletions
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

Lines changed: 0 additions & 12 deletions
This file was deleted.

data/ilsvrc12/get_ilsvrc_aux.sh

Lines changed: 20 additions & 0 deletions
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."
Lines changed: 3 additions & 0 deletions
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

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/imagenet_pretrained.md

Lines changed: 9 additions & 19 deletions
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)