来源:http://www.knight-of-pi.org/deepdreaming-on-a-raspberry-pi-2/
我的环境 树莓派2 ubuntu16.04 ,
按原博的流程做下来好多出错——好像没人能按那个流程直接做出来——可能是环境不同导致的,做了多处小修改后,完美运行了。
另外,还需要一点点耐心:把putty扔后台,有几个地方半天不动,并不是跑死了,隔半天看一下是不是完成了就行……
Hooray, DeepDream runs on a Raspberry Pi 2! Please see the DeepDream on Ubuntu Linux installation tutorial for references, thanks and more comments on the installation or check out this gallery with deepdream images. This installation was tested on a Raspberry Pi 2; older models are probably too slow for running DeepDream, sadly. The complete installation will take around half a day; alternatively, the psychedelic surveilance camera PsyCam, which is based on DeepDream, could be installed from an Disk Image.
Update Ubuntu
First, the Ubuntu packages have to be refreshed. Do this with
1
2
|
sudo
apt
-
get
update
sudo
apt
-
get
upgrade
|
Basic dependency installation
These are the basic dependencies required for installing DeepDream on a Raspberry Pi:
7处 scipy安装超级慢,出去吃个饭啥的比较合适。
1
2
3
4
5
6
7
8
|
sudo
apt
-
get
install
python
-
pip
python
-
dev
sudo
pip
install
numpy
scipy
ipython
jupyter
sudo
apt
-
get
install
gfortran
sudo
apt
-
get
install
-
y
libprotobuf
-
dev
libleveldb
-
dev
libsnappy
-
dev
libopencv
-
dev
libhdf5
-
serial
-
dev
protobuf
-
compiler
git
sudo
apt
-
get
install
--
no
-
install
-
recommends
libboost
-
all
-
dev
sudo
apt
-
get
install
-
y
python
-
dev
libgflags
-
dev
libgoogle
-
glog
-
dev
liblmdb
-
dev
libatlas
-
base
-
dev
sudo
pip
install
numpy
scipy
sudo
pip
install
pyzmq
jsonschema
pillow
|
Caffe installation
Caffe is the neural network engine used for DeepDream. Install it with
1
2
3
4
5
6
7
|
cd
~
mkdir
deepdream
cd
deepdream
git
clone
https
:
//github.com/BVLC/caffe
cd
caffe
cp
Makefile
.
config
.
example
Makefile
.
config
sudo
nano
Makefile
.
config
|
In the now-open file, change the line
1
|
/
usr
/
lib
/
python2
.
7
/
dist
-
packages
/
numpy
/
core
/
include
|
to
1
|
/
usr
/
local
/
lib
/
python2
.
7
/
dist
-
packages
/
numpy
/
core
/
include
|
and replace
1
|
#cpu-only
|
with
1
|
cpu
-
only
|
上面事实上是cpu_only
按照原文编译的时候发生错误,增加两处改动可以解决:
同文件靠近末尾处,添加/usr/include/hdf5/serial/ 到 INCLUDE_DIRS,
改为:
保存。
然后:
sudo nano Makefile
将 LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
改为 LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
下面这处我没有找到,所以也没有改。
#
Then, open db_lmdb.cpp
with sudo nano ./src/caffe/util/db_lmdb.cpp
and change
1
|
1099511627776
|
to
1
|
1073741824
|
#
按下面直接1。make all 失败,所以增加了以下几行:
mkdir build
cd build
cmake ..
然后再make all就OK了
Now, everything is ready for installing caffe. Execute in the terminal
下面的准备半天完成吧……
5 我没有成功,改为 sudo apt-get install python-skimage了
1
2
3
4
5
6
7
8
|
make
all
make
test
make
runtest
make
pycaffe
sudo
pip
install
-
U
scikit
-
image
sudo
pip
install
pyyaml
.
/
scripts
/
download_model_binary
.
py
models
/
bvlc_googlenet
sudo
nano
~
/
.
bashrc
|
In the now open .bashrc
, add at the end of the file
1
|
export
PYTHONPATH
=
/
home
/
ubuntu
/
deepdream
/
caffe
/
python
:
$
PYTHONPATH
|
and reload .bashrc
with
1
|
.
~
/
.
bashrc
|
Protobuf installation
Protobuf is a framework for structured data and necessary for DeepDream. Install it with
行4,改为 cd protcdobuf-2.6.1
行6,改为sudo make
1
2
3
4
5
6
7
8
|
cd
~
/
deepdream
wget
https
:
//github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
tar
xf
protobuf
-
2.6.1.tar.gz
cd
protobuf
-
2.6.1.tar.gz
sudo
.
/
configure
make
sudo
make
install
sudo
nano
~
/
.
bashrc
|
In the now-open .bashrc
, add at the end of the file
1
|
export
LD_LIBRARY_PATH
=
/
usr
/
local
/
lib
|
Then, type in the terminal
1
2
3
4
5
|
.
~
/
.
bashrc
cd
python
python
setup
.
py
build
python
setup
.
py
google_test
sudo
python
setup
.
py
install
|
DeepDream installation
For installing DeepDream, enter
1
2
3
|
cd
~
/
deepdream
git
clone
https
:
//github.com/JoBergs/deepdream
cd
deepdream
|
DeepDream usage
Running the DeepDream notebook was not tested, since loading the graphical Desktop environment takes too much RAM for the already exhausted Raspberry Pi. There is, however, the script deepdreaming.py
in this repository, which lets the Raspberry Pi deepdream from the ubuntu terminal.
Execute the script with
1
|
python
deepdreaming
.
py
-
s
sky_small
.
jpg
-
r
|
运行这一条出现了 no ipython错误,所以 pip install --upgrade IPython
to let the Raspi dream. To get some help, enter
1
|
python
deepdreaming
.
py
--
help
|
Copy the images onto a host computer with scp for watching them.
The script was tested for a maximum input image width of 500px that did not crash the Raspberry Pi; i’d love to hear back if other image sizes work, too. The script is under development right now: another blog post on its usage will follow soon…
The complete script (beta)
Click on Full Script
to show all of the code.