主要参考https://www.2cto.com/kf/201611/561124.html
前言
在这里使用的python安装包是anaconda2,注意使用Python2.7版本的那个安装包。
官网地址:https://www.continuum.io/downloads
百度云:链接:http://pan.baidu.com/s/1nvrrfQx 密码:1jg5
测试的实例是2015年一篇利用噪声生成一张真实图片的代码,使用的caffe+python时下
测试Python是否安装好的方法是直接在dos输入jupyter notebook,看是否有一个网页弹出来。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
C:\Users\Bingo>jupyter
notebook
[I
10:16:40.512
NotebookApp] [nb_conda_kernels] enabled, 2
kernels found
[I
10:16:41.680
NotebookApp] 鉁?nbpresent HTML export ENABLED
[W
10:16:41.680
NotebookApp] 鉁?nbpresent PDF export DISABLED: No module named n
bbrowserpdf.exporters.pdf
[I
10:16:41.690
NotebookApp] [nb_conda] enabled
[I
10:16:41.812
NotebookApp] [nb_anacondacloud] enabled
[I
10:16:42.140
NotebookApp] Serving notebooks from local directory: C:\Users\Bi
ngo
[I
10:16:42.140
NotebookApp] 0
active kernels
[I
10:16:42.141
NotebookApp] The Jupyter Notebook is running at: http://localhos
t:8888/
[I
10:16:42.141
NotebookApp] Use Control-C to stop this
server and shut down all
kernels
(twice to skip confirmation).
|
第一步
编译caffe接口,修改配置文件CommonSettings.props:
第13行:
|
1
|
<pythonsupport>true</pythonsupport>
|
|
1
|
<pythondir>C:\Program
Files\Anaconda2\</pythondir>
|
等编译完成以后,有如下文件夹:
直接将caffe这个文件夹拷贝到C:\Program Files\Anaconda2\Lib\site-packages即可。
第二步
试试import caffe
|
1
2
3
4
5
6
7
8
9
10
|
Microsoft
Windows [版本 6.1.7601]
版权所有
(c) 2009
Microsoft Corporation。保留所有权利。
C:\Users\Bingo>python
Python
2.7.12
|Anaconda 4.2.0
(64-bit)|
(default,
Jun 29
2016,
11:07:13)
[MSC v.
1500
64
bit (AMD64)] on win32
Type
"help",
"copyright",
"credits"
or "license"
for
more information.
Anaconda
is brought to you by Continuum Analytics.
Please
check out: http://continuum.io/thanks
and
https://anaconda.org
>>>
import
caffe
|
|
1
|
ImportError:
No module named google.protobuf.internal
|
|
1
|
C:\windows\system32>conda
install protobuf
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
Microsoft
Windows [版本 6.1.7601]
版权所有
(c) 2009
Microsoft Corporation。保留所有权利。
C:\windows\system32>conda
install protobuf
Fetching
package
metadata ..........Could not connect to https://repo.continuum
io/pkgs/free/win-64/
........
Solving
package
specifications: ..........
Package
plan for
installation in environment C:\Program Files\Anaconda2:
The
following packages will be downloaded:
package
| build
---------------------------|-----------------
conda-env-2.5.2
| py27_0 66
KB conda-forge
conda-4.1.12
| py27_0 263
KB conda-forge
protobuf-3.0.0
| py27_vc9_0 11.1
MB conda-forge
------------------------------------------------------------
Total:
11.4
MB
The
following NEW packages will be INSTALLED:
conda-env:
2.5.2-py27_0
conda-forge
protobuf:
3.0.0-py27_vc9_0
conda-forge [vc9]
The
following packages will be SUPERCEDED by a higher-priority channel:
conda:
4.2.9-py27_0
--> 4.1.12-py27_0
conda-forge
Proceed
([y]/n)? y
Fetching
packages ...
conda-env-2.5.
100%
|###############################| Time: 0:00:01
35.70
kB/s
conda-4.1.12-p
100%
|###############################| Time: 0:00:03
71.46
kB/s
protobuf-3.0.0
100%
|###############################| Time: 0:02:02
94.90
kB/s
Extracting
packages ...
[
COMPLETE ]|##################################################| 100%
Unlinking
packages ...
[
COMPLETE ]|##################################################| 100%
Linking
packages ...
[
COMPLETE ]|##################################################| 100%
C:\windows\system32>
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
Microsoft
Windows [版本 6.1.7601]
版权所有
(c) 2009
Microsoft Corporation。保留所有权利。
C:\Users\Bingo>python
Python
2.7.12
|Anaconda 4.2.0
(64-bit)|
(default,
Jun 29
2016,
11:07:13)
[MSC v.
1500
64
bit (AMD64)] on win32
Type
"help",
"copyright",
"credits"
or "license"
for
more information.
Anaconda
is brought to you by Continuum Analytics.
Please
check out: http://continuum.io/thanks
and
https://anaconda.org
>>>
import
caffe
C:\Program
Files\Anaconda2\lib\site-packages\caffe\pycaffe.py:13:
RuntimeWarning
:
to-Python converter for
class
boost::shared_ptr<class
float="">
> alre
ady
registered; second conversion method ignored.
from
._caffe import
Net, SGDSolver, NesterovSolver, AdaGradSolver, \
C:\Program
Files\Anaconda2\lib\site-packages\caffe\pycaffe.py:13:
RuntimeWarning
:
to-Python converter for
class
boost::shared_ptr<class
float="">
> alr
eady
registered; second conversion method ignored.
from
._caffe import
Net, SGDSolver, NesterovSolver, AdaGradSolver, \
C:\Program
Files\Anaconda2\lib\site-packages\caffe\pycaffe.py:13:
RuntimeWarning
:
to-Python converter for
class
boost::shared_ptr<class
float="">
> a
lready
registered; second conversion method ignored.
from
._caffe import
Net, SGDSolver, NesterovSolver, AdaGradSolver, \
>>></class></class></class>
|
第三步:
使用的实例是Texture Synthesis with Convolutional Neural Networks这篇论文的代码,主要实现的是利用噪声生成一张真实图片。
原文地址:https://arxiv.org/abs/1505.07376
github地址:https://github.com/leongatys/DeepTextures
百度云地址:链接:http://pan.baidu.com/s/1qYaqcZ6 密码:5cm9
使用方法是先打开jupyter notebook
【注意】此处打开的路径是你的代码解压以后的位置
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
Microsoft
Windows [版本 6.1.7601]
版权所有
(c) 2009
Microsoft Corporation。保留所有权利。
C:\Users\Bingo>E:
E:\>cd
E:\caffe-code\DeepTextures-master
E:\caffe-code\DeepTextures-master>jupyter
notebook
[I
10:38:58.658
NotebookApp] [nb_conda_kernels] enabled, 2
kernels found
[I
10:38:59.819
NotebookApp] 鉁?nbpresent HTML export ENABLED
[W
10:38:59.819
NotebookApp] 鉁?nbpresent PDF export DISABLED: No module named n
bbrowserpdf.exporters.pdf
[I
10:38:59.829
NotebookApp] [nb_conda] enabled
[I
10:38:59.951
NotebookApp] [nb_anacondacloud] enabled
[I
10:39:00.283
NotebookApp] Serving notebooks from local directory: E:\caffe-co
de\DeepTextures-master
[I
10:39:00.283
NotebookApp] 0
active kernels
[I
10:39:00.283
NotebookApp] The Jupyter Notebook is running at: http://localhos
t:8888/
[I
10:39:00.285
NotebookApp] Use Control-C to stop this
server and shut down all
kernels
(twice to skip confirmation).
|
然后点击Example.ipynb,使用快捷键shift+Enter逐步运行,最后会出现一个迭代生成过程,就是一张图片一闪一闪的,但是我看其它人的都是由一个iteration数字在上面,不过不管怎么样,这样就是在生成图片了: