Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Deepdream(Caffe-python) on Mac OS X Yosemite 10.10.3 #10

Open
rainyear opened this issue Jul 10, 2015 · 3 comments
Open

Install Deepdream(Caffe-python) on Mac OS X Yosemite 10.10.3 #10

rainyear opened this issue Jul 10, 2015 · 3 comments
Assignees

Comments

@rainyear
Copy link
Owner

Deepdream是最近Google开源的一个很好玩的项目,让我们可以看到利用深度学习对图片进行分类时,相邻神经网络层次之间的信息传递。Deepdream是基于Caffe框架,因此主要是安装Caffe的依赖环境和Caffe框架。

1. 下载 Caffe

git clone https://github.com/BVLC/caffe.git
cd caffe && cp Makefile.config.example Makefile.config

2. 安装 Caffe 依赖

#1. CUDA is required for GPU mode.
# 不采用GPU模式,只需要在 Makefile.config 中修改 
CPU_ONLY := 1

#2. BLAS via ATLAS, MKL, or OpenBLAS.
# Basic Linear Algebra Subprograms,基础线性代数程序集
# 应该是系统有自带了实现方案

#3. Boost >= 1.55
# Deepdream是用Python接Caffe,因此还需要 boost.python 支持

brew install boost --with-python
brew install boost-python

#4. OpenCV >= 2.4 including 3.0
# OpenCV 就不用说了

#5. protobuf, glog, gflags
brew install protobuf
brew install glog
brew install gflags

#6. IO libraries hdf5, leveldb, snappy, lmdb

brew install leveldb
brew install lmdb

brew tap homebrew/science
brew install homebrew/science/hdf5
# python driver for hdf5
pip install h5py

#7. numpy for python
brew install numpy

3. Setup for Python

官方推荐使用Anaconda,包含了大部分可能用到的Python package,然而这里有很大一个坑,Mac下面Anaconda是安装在~/anaconda目录下,要使用~/anaconda/bin/python~/anaconda/bin/ipython而非原系统的Python,这要求所有Homebrew安装的包都必须通过Anaconda下的Python来执行,因此如果从一开始就打算用Anaconda,要注意修改环境变量。

这里不使用Anaconda,注意Makefile.config中提到:

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 

如果是通过Homebrew安装的numpy,需要添加numpy路径,否则会报错:

python/caffe/_caffe.cpp:10:10: fatal error: 'numpy/arrayobject.h' file not found

# Add this to PYTHON_INCLUDE in Makefile.config
PYTHON_INCLUDE := /usr/include/python2.7 \
    /usr/local/Cellar/numpy/1.9.2_1/lib/python2.7/site-packages/numpy/core/include

4. make

make all
make test
make runtest

make pycaffe

都通过之后将 caffe/python/添加到Python系统路径:

export PYTHONPATH=path/to/caffe/python:$PYTHONPATH

测试一下:

python
>>> import caffe

# 可能的错误
ImportError: No module named skimage.io
# 解决
pip install scikit-image

5. Run ipython notebook

git clone https://github.com/google/deepdream.git
cd deepdream && ipython notebook

需要下载 BVLC GoogleNet Modelpath/to/caffe/models/bvlc_googlenet/,然后就可以基于自己的图片,让它做梦给你看!

6. Result

deepdream

🍺BitCoin donate button🍺Tenpay donate button🍺Alipay donate button🍺

@rainyear rainyear added the Note label Jul 10, 2015
@rainyear rainyear mentioned this issue Jul 12, 2015
4 tasks
@viannecc
Copy link

Hi. I encountered a problem about the installation of protobuf.
I typed 'brew install —build-from-source —with-python —fresh -vd protobuf'
But, Homebrew asked me to type interactive mode. I don't know what it is. Could you please help me?

@rainyear rainyear self-assigned this Jul 22, 2015
@zt706
Copy link

zt706 commented Oct 18, 2016

nice, but the opencv 2.4 will get error about cv::VideoCapture. You can modify the Makefile
LIBRARIES += opencv_imgcodecs opencv_videoio ...

@kangkang59812
Copy link

Anaconda安装的时候Makefile.config里那几个变量怎么修改?很迷,thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants