Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
2273e96a
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2273e96a
编写于
2月 28, 2018
作者:
L
liuyang11
浏览文件
操作
浏览文件
下载
差异文件
support lenet and resnet convertion
上级
e15c71cd
eb3fdb8d
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
20 addition
and
14 deletion
+20
-14
fluid/image_classification/caffe2fluid/README.md
fluid/image_classification/caffe2fluid/README.md
+3
-4
fluid/image_classification/caffe2fluid/kaffe/caffe/caffepb.py
...d/image_classification/caffe2fluid/kaffe/caffe/caffepb.py
+0
-1
fluid/image_classification/caffe2fluid/kaffe/caffe/resolver.py
.../image_classification/caffe2fluid/kaffe/caffe/resolver.py
+11
-2
fluid/image_classification/caffe2fluid/kaffe/paddle/network.py
.../image_classification/caffe2fluid/kaffe/paddle/network.py
+0
-2
fluid/image_classification/caffe2fluid/kaffe/paddle/transformer.py
...ge_classification/caffe2fluid/kaffe/paddle/transformer.py
+0
-1
fluid/image_classification/caffe2fluid/tests/lenet/README.md
fluid/image_classification/caffe2fluid/tests/lenet/README.md
+2
-0
fluid/image_classification/caffe2fluid/tests/lenet/convert.sh
...d/image_classification/caffe2fluid/tests/lenet/convert.sh
+2
-0
fluid/image_classification/caffe2fluid/tests/lenet/lenet.py
fluid/image_classification/caffe2fluid/tests/lenet/lenet.py
+2
-4
未找到文件。
fluid/image_classification/caffe2fluid/README.md
浏览文件 @
2273e96a
### caffe2fluid
this tool is used to convert a caffe-model to paddle-model(fluid api)
### howto
0, prepare caffepb.py in ./proto
1, prepare caffepb.py in ./proto, two options provided
option 1: generate it from caffe.proto using protoc
bash ./proto/compile.sh
option2: download one from github directly
cd proto/ && wget https://github.com/ethereon/caffe-tensorflow/blob/master/kaffe/caffe/caffepb.py
1
, convert you caffe model using convert.py which will generate a python code and weight(in .npy)
2
, convert you caffe model using convert.py which will generate a python code and weight(in .npy)
2
, use the converted model to predict
3
, use the converted model to predict
(see more detail info in 'tests/lenet/README.md')
...
...
fluid/image_classification/caffe2fluid/kaffe/caffe/caffepb.py
已删除
120000 → 0
浏览文件 @
e15c71cd
..
/
..
/
proto
/
caffepb
.
py
\ No newline at end of file
fluid/image_classification/caffe2fluid/kaffe/caffe/resolver.py
浏览文件 @
2273e96a
import
os
import
sys
SHARED_CAFFE_RESOLVER
=
None
def
import_caffepb
():
p
=
os
.
path
.
realpath
(
__file__
)
p
=
os
.
path
.
dirname
(
p
)
p
=
os
.
path
.
join
(
p
,
'../../proto'
)
sys
.
path
.
insert
(
0
,
p
)
import
caffepb
return
caffepb
class
CaffeResolver
(
object
):
def
__init__
(
self
):
self
.
import_caffe
()
...
...
@@ -15,8 +25,7 @@ class CaffeResolver(object):
self
.
caffe
=
caffe
except
ImportError
:
# Fall back to the protobuf implementation
from
.
import
caffepb
self
.
caffepb
=
caffepb
self
.
caffepb
=
import_caffepb
()
show_fallback_warning
()
if
self
.
caffe
:
# Use the protobuf code from the imported distribution.
...
...
fluid/image_classification/caffe2fluid/kaffe/paddle/network.py
浏览文件 @
2273e96a
...
...
@@ -165,7 +165,6 @@ class Network(object):
# Get the number of channels in the input
h_i
,
w_i
=
input
.
shape
[
2
:]
fluid
=
import_fluid
()
output
=
fluid
.
layers
.
pool2d
(
input
=
input
,
...
...
@@ -182,7 +181,6 @@ class Network(object):
# Get the number of channels in the input
h_i
,
w_i
=
input
.
shape
[
2
:]
fluid
=
import_fluid
()
output
=
fluid
.
layers
.
pool2d
(
input
=
input
,
...
...
fluid/image_classification/caffe2fluid/kaffe/paddle/transformer.py
浏览文件 @
2273e96a
...
...
@@ -273,7 +273,6 @@ class TensorFlowEmitter(object):
b
+=
self
.
emit_node
(
node
)
blocks
.
append
(
b
[:
-
1
])
s
=
s
+
'
\n\n
'
.
join
(
blocks
)
s
+=
self
.
emit_convert_def
(
input_nodes
)
s
+=
self
.
emit_main_def
(
name
)
return
s
...
...
fluid/image_classification/caffe2fluid/tests/lenet/README.md
浏览文件 @
2273e96a
### convert lenet model from caffe format into paddle format(fluid api)
### howto
0, prepare your caffepb.py
1, download a lenet caffe-model
lenet_iter_10000.caffemodel
download address: https://github.com/ethereon/caffe-tensorflow/raw/master/examples/mnist/lenet_iter_10000.caffemodel
...
...
fluid/image_classification/caffe2fluid/tests/lenet/convert.sh
浏览文件 @
2273e96a
...
...
@@ -2,6 +2,8 @@
#function:
# convert a caffe model
# eg:
# bash ./convert.sh ./model.caffe/lenet.prototxt ./model.caffe/lenet.caffemodel lenet.py lenet.npy
if
[[
$#
-ne
4
]]
;
then
echo
"usage:"
...
...
fluid/image_classification/caffe2fluid/tests/lenet/lenet.py
浏览文件 @
2273e96a
...
...
@@ -61,8 +61,8 @@ class Network(object):
fluid
=
import_fluid
()
#load fluid mode directly
if
os
.
path
.
isdir
(
data_path
):
assert
(
exe
is
not
None
),
'must provide a executor to load fluid model'
assert
(
exe
is
not
None
),
\
'must provide a executor to load fluid model'
fluid
.
io
.
load_persistables_if_exist
(
executor
=
exe
,
dirname
=
data_path
)
return
True
...
...
@@ -167,7 +167,6 @@ class Network(object):
# Get the number of channels in the input
h_i
,
w_i
=
input
.
shape
[
2
:]
fluid
=
import_fluid
()
output
=
fluid
.
layers
.
pool2d
(
input
=
input
,
...
...
@@ -184,7 +183,6 @@ class Network(object):
# Get the number of channels in the input
h_i
,
w_i
=
input
.
shape
[
2
:]
fluid
=
import_fluid
()
output
=
fluid
.
layers
.
pool2d
(
input
=
input
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录