and other fixes and documentation updates.
This commit is contained in:
Evan Shelhamer 2015-01-21 15:43:49 -08:00
Родитель 350d880ea2 6925de1c2e
Коммит 43bae95d7f
23 изменённых файлов: 110 добавлений и 149 удалений

Просмотреть файл

@ -17,15 +17,14 @@ CUDA_DIR := /usr/local/cuda
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr
# CUDA architecture setting: going with all of them (up to CUDA 5.5 compatible).
# For the latest architecture, you need to install CUDA >= 6.0 and uncomment
# the *_50 lines below.
# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
#-gencode arch=compute_50,code=sm_50 \
#-gencode arch=compute_50,code=compute_50
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50
# BLAS choice:
# atlas for ATLAS (default)

Просмотреть файл

@ -2,3 +2,7 @@
Caffe is a deep learning framework developed with cleanliness, readability, and speed in mind.<br />
Consult the [project website](http://caffe.berkeleyvision.org) for all documentation.
Please ask usage questions and how to model different tasks on the [caffe-users mailing list](https://groups.google.com/forum/#!forum/caffe-users).

Просмотреть файл

@ -17,7 +17,7 @@ Networks are specified in simple config files, with no hard-coded parameters in
Switching between CPU and GPU is as simple as setting a flag -- so models can be trained on a GPU machine, and then used on commodity clusters.
**Readable & modifiable implementation** fosters active development.
In Caffe's first six months, it has been forked by over 300 developers on Github, and many have pushed significant changes.
In Caffe's first year, it has been forked by over 600 developers on Github, and many have pushed significant changes.
**Speed** makes Caffe perfect for industry use.
Caffe can process over **40M images per day** with a single NVIDIA K40 or Titan GPU\*.
@ -35,11 +35,11 @@ Consult performance [details](/performance_hardware.html).
## Documentation
- [DIY Deep Learning for Vision with Caffe](https://docs.google.com/presentation/d/1UeKXVgRvvxg9OUdh_UiC5G71UMscNPlvArsWER41PsU/edit#slide=id.p)<br>
Caffe tutorial slides.
- [ACM MM paper](http://ucb-icsi-vision-group.github.io/caffe-paper/caffe.pdf)<br>
A 4-page report for the ACM Multimedia Open Source competition.
- [Caffe Tutorial](/tutorial)<br>
DIY deep learning with this hands-on tutorial to Caffe.
Tutorial presentation.
- [Tutorial Documentation](/tutorial)<br>
Practical guide and framework reference.
- [arXiv / ACM MM '14 paper](http://arxiv.org/abs/1408.5093)<br>
A 4-page report for the ACM Multimedia Open Source competition (arXiv:1408.5093v1).
- [Installation instructions](/installation.html)<br>
Tested on Ubuntu, Red Hat, OS X.
* [Model Zoo](/model_zoo.html)<br>
@ -67,11 +67,11 @@ Developer documentation automagically generated from code comments.
Please cite Caffe in your publications if it helps your research:
@misc{Jia13caffe,
Author = {Yangqing Jia},
Title = { {Caffe}: An Open Source Convolutional Architecture for Fast Feature Embedding},
Year = {2013},
Howpublished = {\url{http://caffe.berkeleyvision.org/}}
@article{jia2014caffe,
Author = {Jia, Yangqing and Shelhamer, Evan and Donahue, Jeff and Karayev, Sergey and Long, Jonathan and Girshick, Ross and Guadarrama, Sergio and Darrell, Trevor},
Journal = {arXiv preprint arXiv:1408.5093},
Title = {Caffe: Convolutional Architecture for Fast Feature Embedding},
Year = {2014}
}
If you do publish a paper where Caffe helped your research, we encourage you to update the [publications wiki](https://github.com/BVLC/caffe/wiki/Publications).
@ -79,17 +79,19 @@ Citations are also tracked automatically by [Google Scholar](http://scholar.goog
## Acknowledgements
Yangqing would like to thank the NVIDIA Academic program for providing GPUs, [Oriol Vinyals](http://www1.icsi.berkeley.edu/~vinyals/) for discussions along the journey, and BVLC PI [Trevor Darrell](http://www.eecs.berkeley.edu/~trevor/) for guidance.
The BVLC Caffe developers would like to thank NVIDIA for GPU donation, A9 and Amazon Web Services for a research grant in support of Caffe development and reproducible research in deep learning, and BVLC PI [Trevor Darrell](http://www.eecs.berkeley.edu/~trevor/) for guidance.
A core set of BVLC members have contributed much new functionality and many fixes since the original release (alphabetical by first name):
[Eric Tzeng](https://github.com/erictzeng), [Evan Shelhamer](http://imaginarynumber.net/), [Jeff Donahue](http://jeffdonahue.com/), [Jon Long](https://github.com/longjon), [Ross Girshick](http://www.cs.berkeley.edu/~rbg/), [Sergey Karayev](http://sergeykarayev.com/), [Sergio Guadarrama](http://www.eecs.berkeley.edu/~sguada/).
The BVLC members who have contributed to Caffe are (alphabetical by first name):
[Eric Tzeng](https://github.com/erictzeng), [Evan Shelhamer](http://imaginarynumber.net/), [Jeff Donahue](http://jeffdonahue.com/), [Jon Long](https://github.com/longjon), [Ross Girshick](http://www.cs.berkeley.edu/~rbg/), [Sergey Karayev](http://sergeykarayev.com/), [Sergio Guadarrama](http://www.eecs.berkeley.edu/~sguada/), and [Yangqing Jia](http://daggerfs.com/).
Additionally, the open-source community plays a large and growing role in Caffe's development.
The open-source community plays an important and growing role in Caffe's development.
Check out the Github [project pulse](https://github.com/BVLC/caffe/pulse) for recent activity, and the [contributors](https://github.com/BVLC/caffe/graphs/contributors) for a sorted list.
We sincerely appreciate your interest and contributions!
If you'd like to contribute, please read the [developing & contributing](development.html) guide.
Yangqing would like to give a personal thanks to the NVIDIA Academic program for providing GPUs, [Oriol Vinyals](http://www1.icsi.berkeley.edu/~vinyals/) for discussions along the journey, and BVLC PI [Trevor Darrell](http://www.eecs.berkeley.edu/~trevor/) for advice.
## Contacting us
All questions about usage, installation, code, and applications should be searched for and asked on the [caffe-users mailing list](https://groups.google.com/forum/#!forum/caffe-users).

Просмотреть файл

@ -17,7 +17,7 @@ Caffe depends on several software packages.
* [CUDA](https://developer.nvidia.com/cuda-zone) library version 6.5 (recommended), 6.0, 5.5, or 5.0 and the latest driver version for CUDA 6 or 319.* for CUDA 5 (and NOT 331.*)
* [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) (provided via ATLAS, MKL, or OpenBLAS).
* [OpenCV](http://opencv.org/).
* [OpenCV](http://opencv.org/) (>= 2.4)
* [Boost](http://www.boost.org/) (>= 1.55, although only 1.55 and 1.56 are tested)
* `glog`, `gflags`, `protobuf`, `leveldb`, `snappy`, `hdf5`, `lmdb`
* For the Python wrapper

Просмотреть файл

@ -15,7 +15,7 @@ This pass goes from bottom to top.
<img src="fig/forward.jpg" alt="Forward pass" width="320">
The data $x$ is passed through an inner product layer for $g(x)$ then through a softmax for $h(g(x))$ and softmax loss to give $f_W(x)$.
The data $$x$$ is passed through an inner product layer for $$g(x)$$ then through a softmax for $$h(g(x))$$ and softmax loss to give $$f_W(x)$$.
The **backward** pass computes the gradient given the loss for learning.
In backward Caffe reverse-composes the gradient of each layer to compute the gradient of the whole model by automatic differentiation.
@ -24,7 +24,7 @@ This pass goes from top to bottom.
<img src="fig/backward.jpg" alt="Backward pass" width="320">
The backward pass begins with the loss and computes the gradient with respect to the output $\frac{\partial f_W}{\partial h}$. The gradient with respect to the rest of the model is computed layer-by-layer through the chain rule. Layers with parameters, like the `INNER_PRODUCT` layer, compute the gradient with respect to their parameters $\frac{\partial f_W}{\partial W_{\text{ip}}}$ during the backward step.
The backward pass begins with the loss and computes the gradient with respect to the output $$\frac{\partial f_W}{\partial h}$$. The gradient with respect to the rest of the model is computed layer-by-layer through the chain rule. Layers with parameters, like the `INNER_PRODUCT` layer, compute the gradient with respect to their parameters $$\frac{\partial f_W}{\partial W_{\text{ip}}}$$ during the backward step.
These computations follow immediately from defining the model: Caffe plans and carries out the forward and backward passes for you.

Просмотреть файл

@ -24,8 +24,8 @@ You will first need to download and convert the data format from the [CIFAR-10 w
cd $CAFFE_ROOT/data/cifar10
./get_cifar10.sh
cd $CAFFE_ROOT/examples/cifar10
./create_cifar10.sh
cd $CAFFE_ROOT
./examples/cifar10/create_cifar10.sh
If it complains that `wget` or `gunzip` are not installed, you need to install them respectively. After running the script there should be the dataset, `./cifar10-leveldb`, and the data set image mean `./mean.binaryproto`.
@ -39,8 +39,8 @@ Training and Testing the "Quick" Model
Training the model is simple after you have written the network definition protobuf and solver protobuf files (refer to [MNIST Tutorial](../examples/mnist.html)). Simply run `train_quick.sh`, or the following command directly:
cd $CAFFE_ROOT/examples/cifar10
./train_quick.sh
cd $CAFFE_ROOT
./examples/cifar10/train_quick.sh
`train_quick.sh` is a simple script, so have a look inside. The main tool for training is `caffe` with the `train` action, and the solver protobuf text file as its argument.

Просмотреть файл

@ -3,7 +3,8 @@
"description": "Use the pre-trained ImageNet model to classify images with the Python interface.",
"example_name": "ImageNet classification",
"include_in_docs": true,
"priority": 1
"priority": 1,
"signature": "sha256:2caae2c1fe3e282b8f836d380a45622351c91db18a1591e4f2fa67faba9ab72c"
},
"nbformat": 3,
"nbformat_minor": 0,
@ -19,7 +20,7 @@
"\n",
"Caffe provides a general Python interface for models with `caffe.Net` in `python/caffe/pycaffe.py`, but to make off-the-shelf classification easy we provide a `caffe.Classifier` class and `classify.py` script. Both Python and MATLAB wrappers are provided. However, the Python wrapper has more features so we will describe it here. For MATLAB, refer to `matlab/caffe/matcaffe_demo.m`.\n",
"\n",
"Before we begin, you must compile Caffe and install the python wrapper by setting your `PYTHONPATH`. If you haven't yet done so, please refer to the [installation instructions](installation.html). This example uses our pre-trained CaffeNet model, an ILSVRC12 image classifier. You can download it by running `./scripts/download_model_binary.py models/bvlc_reference_caffenet`. Note that this pre-trained model is licensed for academic research / non-commercial use only.\n",
"Before we begin, you must compile Caffe and install the python wrapper by setting your `PYTHONPATH`. If you haven't yet done so, please refer to the [installation instructions](installation.html). This example uses our pre-trained CaffeNet model, an ILSVRC12 image classifier. You can download it by running `./scripts/download_model_binary.py models/bvlc_reference_caffenet`.\n",
"\n",
"Ready? Let's start."
]
@ -54,13 +55,17 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Loading a network is easy. `caffe.Classifier` takes care of everything. Note the arguments for configuring input preprocessing: mean subtraction switched on by giving a mean array, input channel swapping takes care of mapping RGB into the reference ImageNet model's BGR order, and raw scaling multiplies the feature scale from the input [0,1] to the ImageNet model's [0,255]."
"Loading a network is easy. `caffe.Classifier` takes care of everything. Note the arguments for configuring input preprocessing: mean subtraction switched on by giving a mean array, input channel swapping takes care of mapping RGB into the reference ImageNet model's BGR order, and raw scaling multiplies the feature scale from the input [0,1] to the ImageNet model's [0,255].\n",
"\n",
"We will set the phase to test since we are doing testing, and will first use CPU for the computation."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"caffe.set_phase_test()\n",
"caffe.set_mode_cpu()\n",
"net = caffe.Classifier(MODEL_FILE, PRETRAINED,\n",
" mean=np.load(caffe_root + 'python/caffe/imagenet/ilsvrc_2012_mean.npy'),\n",
" channel_swap=(2,1,0),\n",
@ -72,25 +77,6 @@
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will set the phase to test since we are doing testing, and will first use CPU for the computation."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"net.set_phase_test()\n",
"net.set_mode_cpu()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
@ -111,7 +97,7 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"prompt_number": 3,
"text": [
"<matplotlib.image.AxesImage at 0x7fda204c0e10>"
]
@ -125,7 +111,7 @@
]
}
],
"prompt_number": 4
"prompt_number": 3
},
{
"cell_type": "markdown",
@ -163,7 +149,7 @@
]
}
],
"prompt_number": 5
"prompt_number": 4
},
{
"cell_type": "markdown",
@ -205,7 +191,7 @@
]
}
],
"prompt_number": 6
"prompt_number": 5
},
{
"cell_type": "markdown",
@ -233,7 +219,7 @@
]
}
],
"prompt_number": 7
"prompt_number": 6
},
{
"cell_type": "markdown",
@ -266,7 +252,7 @@
]
}
],
"prompt_number": 8
"prompt_number": 7
},
{
"cell_type": "markdown",
@ -279,12 +265,12 @@
"cell_type": "code",
"collapsed": false,
"input": [
"net.set_mode_gpu()"
"caffe.set_mode_gpu()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 9
"prompt_number": 8
},
{
"cell_type": "markdown",
@ -314,7 +300,7 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 10,
"prompt_number": 9,
"text": [
"[<matplotlib.lines.Line2D at 0x7fda1ac309d0>]"
]
@ -328,7 +314,7 @@
]
}
],
"prompt_number": 10
"prompt_number": 9
},
{
"cell_type": "markdown",
@ -355,7 +341,7 @@
]
}
],
"prompt_number": 11
"prompt_number": 10
},
{
"cell_type": "code",
@ -375,7 +361,7 @@
]
}
],
"prompt_number": 12
"prompt_number": 11
},
{
"cell_type": "markdown",
@ -404,4 +390,4 @@
"metadata": {}
}
]
}
}

Просмотреть файл

@ -3,7 +3,8 @@
"description": "Extracting features and visualizing trained filters with an example image, viewed layer-by-layer.",
"example_name": "Filter visualization",
"include_in_docs": true,
"priority": 2
"priority": 2,
"signature": "sha256:526501b358e0f60c489eaf5799e8603a75019cc65401533baa307b5603fdefa1"
},
"nbformat": 3,
"nbformat_minor": 0,
@ -61,10 +62,10 @@
"cell_type": "code",
"collapsed": false,
"input": [
"caffe.set_phase_test()\n",
"caffe.set_mode_cpu()\n",
"net = caffe.Classifier(caffe_root + 'models/bvlc_reference_caffenet/deploy.prototxt',\n",
" caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel')\n",
"net.set_phase_test()\n",
"net.set_mode_cpu()\n",
"# input preprocessing: 'data' is the name of the input blob == net.inputs[0]\n",
"net.set_mean('data', np.load(caffe_root + 'python/caffe/imagenet/ilsvrc_2012_mean.npy')) # ImageNet mean\n",
"net.set_raw_scale('data', 255) # the reference model operates on images in [0,255] range instead of [0,1]\n",
@ -598,4 +599,4 @@
"metadata": {}
}
]
}
}

Просмотреть файл

@ -4,7 +4,7 @@
"example_name": "Editing model parameters",
"include_in_docs": true,
"priority": 5,
"signature": "sha256:179fb20339497f5e64f6fbeb57987f27a962b7ae6d940c8fede2631aba9bffaf"
"signature": "sha256:bf84bcbd78fe007310f86d71c5969ba4205b6e06f408029860eec94821844bee"
},
"nbformat": 3,
"nbformat_minor": 0,
@ -279,9 +279,10 @@
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"\n",
"caffe.set_phase_test()\n",
"\n",
"# load input and configure preprocessing\n",
"im = caffe.io.load_image('images/cat.jpg')\n",
"net_full_conv.set_phase_test()\n",
"net_full_conv.set_mean('data', np.load('../python/caffe/imagenet/ilsvrc_2012_mean.npy'))\n",
"net_full_conv.set_channel_swap('data', (2,1,0))\n",
"net_full_conv.set_raw_scale('data', 255.0)\n",
@ -352,4 +353,4 @@
"metadata": {}
}
]
}
}

Просмотреть файл

@ -3,21 +3,13 @@
#include "caffe/common.hpp"
namespace caffe {
/**
* A minimal wrapper for boost::thread to force host compilation for boost
* Defined in caffe/util/thread.hpp
Forward declare boost::thread instead of including boost/thread.hpp
to avoid a boost/NVCC issues (#1009, #1010) on OSX.
*/
class Thread {
public:
template<typename Callable, class A1>
Thread(Callable func, A1 a1);
void join();
bool joinable();
private:
void* thread_;
};
namespace boost { class thread; }
namespace caffe {
/**
* Virtual class encapsulate boost::thread for use in base class
@ -26,7 +18,7 @@ class Thread {
*/
class InternalThread {
public:
InternalThread() : thread_(NULL) {}
InternalThread() : thread_() {}
virtual ~InternalThread();
/** Returns true if the thread was successfully started. **/
@ -35,16 +27,16 @@ class InternalThread {
/** Will not return until the internal thread has exited. */
bool WaitForInternalThreadToExit();
bool is_started() const { return thread_ != NULL && thread_->joinable(); }
bool is_started() const;
protected:
/* Implement this method in your subclass
with the code you want your thread to run. */
virtual void InternalThreadEntry() {}
caffe::Thread* thread_;
shared_ptr<boost::thread> thread_;
};
} // namespace caffe
#endif
#endif // CAFFE_INTERNAL_THREAD_HPP_

Просмотреть файл

@ -1,25 +0,0 @@
#ifndef CAFFE_THREAD_CPP_HPP_
#define CAFFE_THREAD_CPP_HPP_
#include <boost/thread.hpp>
#include "caffe/common.hpp"
#include "caffe/internal_thread.hpp"
namespace caffe {
template<typename Callable, class A1>
Thread::Thread(Callable func, A1 a1) {
this->thread_ = new boost::thread(func, a1);
}
void Thread::join() {
static_cast<boost::thread*>(this->thread_)->join();
}
bool Thread::joinable() {
return static_cast<boost::thread*>(this->thread_)->joinable();
}
} // namespace caffe
#endif

Просмотреть файл

@ -2,7 +2,7 @@
name: BVLC AlexNet Model
caffemodel: bvlc_alexnet.caffemodel
caffemodel_url: http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel
license: non-commercial
license: unrestricted
sha1: 9116a64c0fbe4459d18f4bb6b56d647b63920377
caffe_commit: 709dc15af4a06bebda027c1eb2b3f3e3375d5077
---
@ -22,6 +22,4 @@ This model was trained by Evan Shelhamer @shelhamer
## License
The data used to train this model comes from the ImageNet project, which distributes its database to researchers who agree to a following term of access:
"Researcher shall use the Database only for non-commercial research and educational purposes."
Accordingly, this model is distributed under a non-commercial license.
This model is released for unrestricted use.

Просмотреть файл

@ -2,7 +2,7 @@
name: BVLC CaffeNet Model
caffemodel: bvlc_reference_caffenet.caffemodel
caffemodel_url: http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel
license: non-commercial
license: unrestricted
sha1: 4c8d77deb20ea792f84eb5e6d0a11ca0a8660a46
caffe_commit: 709dc15af4a06bebda027c1eb2b3f3e3375d5077
---
@ -22,6 +22,4 @@ This model was trained by Jeff Donahue @jeffdonahue
## License
The data used to train this model comes from the ImageNet project, which distributes its database to researchers who agree to a following term of access:
"Researcher shall use the Database only for non-commercial research and educational purposes."
Accordingly, this model is distributed under a non-commercial license.
This model is released for unrestricted use.

Просмотреть файл

@ -2,7 +2,7 @@
name: BVLC Reference RCNN ILSVRC13 Model
caffemodel: bvlc_reference_rcnn_ilsvrc13.caffemodel
caffemodel_url: http://dl.caffe.berkeleyvision.org/bvlc_reference_rcnn_ilsvrc13.caffemodel
license: non-commercial
license: unrestricted
sha1: bdd8abb885819cba5e2fe1eb36235f2319477e64
caffe_commit: a7e397abbda52c0b90323c23ab95bdeabee90a98
---
@ -17,6 +17,4 @@ This model was trained by Ross Girshick @rbgirshick
## License
The data used to train this model comes from the ImageNet project, which distributes its database to researchers who agree to a following term of access:
"Researcher shall use the Database only for non-commercial research and educational purposes."
Accordingly, this model is distributed under a non-commercial license.
This model is released for unrestricted use.

Просмотреть файл

@ -1,4 +1,6 @@
from .pycaffe import Net, SGDSolver
from .pycaffe import set_mode_cpu, set_mode_gpu, set_phase_train, set_phase_test
from .pycaffe import set_device
from .classifier import Classifier
from .detector import Detector
import io

Просмотреть файл

@ -148,6 +148,13 @@ void PySGDSolver::SolveResume(const string& resume_file) {
}
BOOST_PYTHON_MODULE(_caffe) {
// Caffe utility methods
bp::def("set_mode_cpu", &set_mode_cpu);
bp::def("set_mode_gpu", &set_mode_gpu);
bp::def("set_phase_train", &set_phase_train);
bp::def("set_phase_test", &set_phase_test);
bp::def("set_device", &Caffe::SetDevice);
// below, we prepend an underscore to methods that will be replaced
// in Python
bp::class_<PyNet, shared_ptr<PyNet> >(
@ -158,11 +165,6 @@ BOOST_PYTHON_MODULE(_caffe) {
.def("_forward", &PyNet::Forward)
.def("_backward", &PyNet::Backward)
.def("reshape", &PyNet::Reshape)
.def("set_mode_cpu", &PyNet::set_mode_cpu)
.def("set_mode_gpu", &PyNet::set_mode_gpu)
.def("set_phase_train", &PyNet::set_phase_train)
.def("set_phase_test", &PyNet::set_phase_test)
.def("set_device", &PyNet::set_device)
.add_property("_blobs", &PyNet::blobs)
.add_property("layers", &PyNet::layers)
.add_property("_blob_names", &PyNet::blob_names)

Просмотреть файл

@ -20,6 +20,12 @@ using boost::shared_ptr;
namespace caffe {
// Selecting mode and phase.
void set_mode_cpu() { Caffe::set_mode(Caffe::CPU); }
void set_mode_gpu() { Caffe::set_mode(Caffe::GPU); }
void set_phase_train() { Caffe::set_phase(Caffe::TRAIN); }
void set_phase_test() { Caffe::set_phase(Caffe::TEST); }
// wrap shared_ptr<Blob> in a class that we construct in C++ and pass
// to Python
template <typename Dtype>
@ -117,13 +123,6 @@ class PyNet {
WriteProtoToBinaryFile(net_param, filename.c_str());
}
// The caffe::Caffe utility functions.
void set_mode_cpu() { Caffe::set_mode(Caffe::CPU); }
void set_mode_gpu() { Caffe::set_mode(Caffe::GPU); }
void set_phase_train() { Caffe::set_phase(Caffe::TRAIN); }
void set_phase_test() { Caffe::set_phase(Caffe::TEST); }
void set_device(int device_id) { Caffe::SetDevice(device_id); }
vector<PyBlob<float> > blobs() {
return vector<PyBlob<float> >(net_->blobs().begin(), net_->blobs().end());
}

Просмотреть файл

@ -24,12 +24,12 @@ class Classifier(caffe.Net):
preprocessing options.
"""
caffe.Net.__init__(self, model_file, pretrained_file)
self.set_phase_test()
caffe.set_phase_test()
if gpu:
self.set_mode_gpu()
caffe.set_mode_gpu()
else:
self.set_mode_cpu()
caffe.set_mode_cpu()
if mean is not None:
self.set_mean(self.inputs[0], mean)

Просмотреть файл

@ -36,12 +36,12 @@ class Detector(caffe.Net):
R-CNN feature extraction.
"""
caffe.Net.__init__(self, model_file, pretrained_file)
self.set_phase_test()
caffe.set_phase_test()
if gpu:
self.set_mode_gpu()
caffe.set_mode_gpu()
else:
self.set_mode_cpu()
caffe.set_mode_cpu()
if mean is not None:
self.set_mean(self.inputs[0], mean)

Просмотреть файл

@ -8,6 +8,8 @@ from itertools import izip_longest
import numpy as np
from ._caffe import Net, SGDSolver
from ._caffe import set_mode_cpu, set_mode_gpu, set_phase_train, set_phase_test
from ._caffe import set_device
import caffe.io
# We directly update methods from Net here (rather than using composition or

Просмотреть файл

@ -13,3 +13,4 @@ pandas>=0.12.0
python-dateutil>=1.4,<2
protobuf>=2.5.0
python-gflags>=2.0
pyyaml>=3.10

Просмотреть файл

@ -3,7 +3,7 @@
PORT=${1:-4000}
echo "usage: build.sh [port]"
echo "usage: build_docs.sh [port]"
# Find the docs dir, no matter where the script is called
ROOT_DIR="$( cd "$(dirname "$0")"/.. ; pwd -P )"

Просмотреть файл

@ -1,23 +1,24 @@
#include <boost/thread.hpp>
#include "caffe/internal_thread.hpp"
#include "caffe/util/thread.hpp"
namespace caffe {
InternalThread::~InternalThread() {
WaitForInternalThreadToExit();
if (thread_ != NULL) {
delete thread_;
}
}
bool InternalThread::is_started() const {
return thread_.get() != NULL && thread_->joinable();
}
bool InternalThread::StartInternalThread() {
if (!WaitForInternalThreadToExit()) {
return false;
}
try {
thread_ = new caffe::Thread
(&InternalThread::InternalThreadEntry, this);
thread_.reset(
new boost::thread(&InternalThread::InternalThreadEntry, this));
} catch (...) {
return false;
}