Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
6aec2006
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6aec2006
编写于
10月 18, 2018
作者:
R
Ray Liu
提交者:
GitHub
10月 18, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1142 from xiebaiyuan/develop_python_develop
add mobile net convert tools && fix bug in deepwises2p0 close
#1141
上级
37314e68
ab1a2638
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
248 addition
and
66 deletion
+248
-66
src/operators/math/depthwise_conv_3x3.cpp
src/operators/math/depthwise_conv_3x3.cpp
+22
-17
tools/op.cmake
tools/op.cmake
+1
-0
tools/python/imagetools/img2nchw.py
tools/python/imagetools/img2nchw.py
+4
-4
tools/python/imagetools/numpy2binary.py
tools/python/imagetools/numpy2binary.py
+9
-7
tools/python/modeltools/core/op_types.py
tools/python/modeltools/core/op_types.py
+8
-0
tools/python/modeltools/mobilenet/converter_mobilenet.py
tools/python/modeltools/mobilenet/converter_mobilenet.py
+191
-29
tools/python/modeltools/mobilenet/swicher.py
tools/python/modeltools/mobilenet/swicher.py
+9
-5
tools/python/modeltools/yolo/swicher.py
tools/python/modeltools/yolo/swicher.py
+4
-4
未找到文件。
src/operators/math/depthwise_conv_3x3.cpp
浏览文件 @
6aec2006
...
...
@@ -1667,7 +1667,7 @@ void DepthwiseConvAddBNRelu3x3s2p1v2(const Tensor *input, const Tensor *filter,
const
int
w_times
=
(
out_w
-
2
)
/
3
;
float32x4_t
zero
=
vdupq_n_f32
(
0.0
);
for
(
int
b
=
batch_size
;
b
>
0
;
--
b
)
{
#pragma omp parallel for
#pragma omp parallel for
for
(
int
j
=
0
;
j
<
c
;
j
++
)
{
const
float
*
input_row_ptr
;
float
*
output_row_ptr
;
...
...
@@ -1901,7 +1901,9 @@ void DepthwiseConv3x3s2p0(const Tensor *input, const Tensor *filter,
for
(
int
c
=
0
;
c
<
input_channel
;
c
++
)
{
const
float
*
filter_data
=
filter
->
data
<
float
>
()
+
c
*
9
;
const
float
*
input_data
=
input
->
data
<
float
>
()
+
c
*
inhxw
;
const
float
*
bias_data
=
bias
.
data
<
float
>
()
+
c
;
if
(
if_bias
)
{
const
float
*
bias_data
=
bias
.
data
<
float
>
()
+
c
;
}
float
*
output_data
=
output
->
data
<
float
>
()
+
c
*
outhxw
;
float
w00
=
filter_data
[
0
];
float
w01
=
filter_data
[
1
];
...
...
@@ -1912,9 +1914,9 @@ void DepthwiseConv3x3s2p0(const Tensor *input, const Tensor *filter,
float
w20
=
filter_data
[
6
];
float
w21
=
filter_data
[
7
];
float
w22
=
filter_data
[
8
];
float32x4_t
biasv
=
vld1q_dup_f32
(
bias_data
);
if
(
if_bias
)
{
float32x4_t
biasv
=
vld1q_dup_f32
(
bias_data
);
}
for
(
int
i
=
0
;
i
<
output_height
;
i
+=
1
)
{
for
(
int
m
=
0
;
m
<
output_width
-
2
;
m
+=
3
)
{
float
*
output_ptr
=
output_data
+
i
*
output_width
+
m
;
...
...
@@ -1949,8 +1951,9 @@ void DepthwiseConv3x3s2p0(const Tensor *input, const Tensor *filter,
out0
=
vmlaq_n_f32
(
out0
,
in4
,
w20
);
out0
=
vmlaq_n_f32
(
out0
,
tmp4
,
w21
);
out0
=
vmlaq_n_f32
(
out0
,
tmp5
,
w22
);
out0
=
vaddq_f32
(
out0
,
biasv
);
if
(
if_bias
)
{
out0
=
vaddq_f32
(
out0
,
biasv
);
}
vst1q_lane_f32
(
output_ptr
,
out0
,
0
);
vst1q_lane_f32
(
output_ptr
+
1
,
out0
,
1
);
vst1q_lane_f32
(
output_ptr
+
2
,
out0
,
2
);
...
...
@@ -1960,16 +1963,18 @@ void DepthwiseConv3x3s2p0(const Tensor *input, const Tensor *filter,
}
for
(
int
j
=
m
;
j
<
output_width
;
j
++
)
{
output_data
[
i
*
output_width
+
j
]
=
input_data
[(
2
*
i
-
1
)
*
input_width
+
2
*
j
-
1
]
*
w00
+
input_data
[(
2
*
i
-
1
)
*
input_width
+
2
*
j
]
*
w01
+
input_data
[(
2
*
i
-
1
)
*
input_width
+
2
*
j
+
1
]
*
w02
+
input_data
[(
2
*
i
)
*
input_width
+
2
*
j
-
1
]
*
w10
+
input_data
[(
2
*
i
)
*
input_width
+
2
*
j
]
*
w11
+
input_data
[(
2
*
i
)
*
input_width
+
2
*
j
+
1
]
*
w12
+
input_data
[(
2
*
i
+
1
)
*
input_width
+
2
*
j
-
1
]
*
w20
+
input_data
[(
2
*
i
+
1
)
*
input_width
+
2
*
j
]
*
w21
+
input_data
[(
2
*
i
+
1
)
*
input_width
+
2
*
j
+
1
]
*
w22
;
output_data
[
i
*
output_width
+
j
]
+=
*
bias_data
;
input_data
[(
2
*
i
)
*
input_width
+
2
*
j
]
*
w00
+
input_data
[(
2
*
i
)
*
input_width
+
2
*
j
+
1
]
*
w01
+
input_data
[(
2
*
i
)
*
input_width
+
2
*
j
+
2
]
*
w02
+
input_data
[(
2
*
i
+
1
)
*
input_width
+
2
*
j
]
*
w10
+
input_data
[(
2
*
i
+
1
)
*
input_width
+
2
*
j
+
1
]
*
w11
+
input_data
[(
2
*
i
+
1
)
*
input_width
+
2
*
j
+
2
]
*
w12
+
input_data
[(
2
*
i
+
2
)
*
input_width
+
2
*
j
]
*
w20
+
input_data
[(
2
*
i
+
2
)
*
input_width
+
2
*
j
+
1
]
*
w21
+
input_data
[(
2
*
i
+
2
)
*
input_width
+
2
*
j
+
2
]
*
w22
;
if
(
if_bias
)
{
output_data
[
i
*
output_width
+
j
]
+=
*
bias_data
;
}
}
}
}
...
...
tools/op.cmake
浏览文件 @
6aec2006
...
...
@@ -33,6 +33,7 @@ if (CON GREATER -1)
set
(
POOL_OP ON
)
set
(
RESHAPE_OP ON
)
set
(
FUSION_CONVADDBNRELU_OP ON
)
set
(
FUSION_CONVADDRELU_OP ON
)
set
(
FUSION_CONVADD_OP ON
)
set
(
FOUND_MATCH ON
)
...
...
tools/python/imagetools/img2nchw.py
浏览文件 @
6aec2006
...
...
@@ -45,13 +45,13 @@ def combine_bgrs_nchw(bgrs, means_b_g_r, scale, channel_type=ChannelType.BGR):
print
'------------------'
print
bgrs_float_array
[
0
]
print
bgrs_float_array
[
416
*
416
*
2
+
416
*
2
+
2
]
print
bgrs_float_array
[
224
*
224
*
2
+
224
*
2
+
2
]
# for i in range(0, 9):
# print'bs %d' % i
# print bs[i] / 255.
print
bs
[
416
*
2
+
2
]
/
255.
print
bs
[
224
*
2
+
2
]
/
255.
print
'--------------combine_bgrs_nchw-----------------end'
return
bgrs_float_array
...
...
@@ -64,6 +64,6 @@ def combine_bgrs_nchw(bgrs, means_b_g_r, scale, channel_type=ChannelType.BGR):
# cv2.waitKey(0)
bgrs
=
tools
.
resize_take_rgbs
(
'datas/
newyolo.jpg'
,
(
416
,
416
,
3
))
bgrs
=
tools
.
resize_take_rgbs
(
'datas/
jpgs/0000_0.9834-148196_82452-0ad4b83ec6bc0f9c5f28101539267054.jpg_p0_0.126571263346.jpg'
,
(
224
,
224
,
3
))
array
=
combine_bgrs_nchw
(
bgrs
,
(
0
,
0
,
0
),
1.
/
255
,
ChannelType
.
RGB
)
tools
.
save_to_file
(
'datas/desktop_1_3_
416_416
_nchw_float'
,
array
)
tools
.
save_to_file
(
'datas/desktop_1_3_
224_224
_nchw_float'
,
array
)
tools/python/imagetools/numpy2binary.py
浏览文件 @
6aec2006
...
...
@@ -15,11 +15,11 @@ from array import array
# image.resize(shape_h_w)
data
=
np
.
fromfile
(
'
datas/img.res
'
)
data
=
np
.
fromfile
(
'
/Users/xiebaiyuan/PaddleProject/paddle-mobile/tools/python/imagetools/datas/jpgs2/0000_0.9834-148196_82452-0ad4b83ec6bc0f9c5f28101539267054.jpg_p0_0.126571263346.jpg.input.npfile'
,
'f
'
)
print
data
.
size
print
data
[
0
]
print
data
data
.
reshape
(
1
,
3
,
416
,
416
)
data
.
reshape
(
1
,
3
,
224
,
224
)
out_array
=
array
(
'f'
)
print
'--------------------'
print
data
.
size
...
...
@@ -27,12 +27,12 @@ print data[0]
print
'如果是nhwc --------'
# rgb rgb rgb rgb rgb
print
data
[
416
*
3
*
2
+
3
*
2
+
2
]
print
data
[
224
*
3
*
2
+
3
*
2
+
2
]
# print data[2]
print
'如果是nchw --------'
# rgb rgb rgb rgb rgb
print
data
[
416
*
416
*
2
+
416
*
2
+
2
]
print
data
[
224
*
224
*
2
+
224
*
2
+
2
]
# print data[2]
# 明明是nchw
...
...
@@ -42,6 +42,8 @@ for i in range(0, data.size):
print
len
(
out_array
)
print
out_array
[
416
*
416
*
2
+
416
*
2
+
2
]
print
out_array
[
224
*
224
*
2
+
224
*
2
+
2
]
# print out_array
tools
.
save_to_file
(
'datas/in_put_1_3_
416_416_2
'
,
out_array
)
tools
.
save_to_file
(
'datas/in_put_1_3_
224_224_nchw
'
,
out_array
)
tools/python/modeltools/core/op_types.py
浏览文件 @
6aec2006
...
...
@@ -77,6 +77,14 @@ fusion_conv_add_attrs_dict = {
'strides'
:
'stride'
,
'groups'
:
'group'
}
# fluid attr key --- mdl params key
pool2d_attrs_dict
=
{
'global_pooling'
:
'global_pooling'
,
'pooling_type'
:
'type'
}
# fluid attr key --- mdl params key
fluid_attrs_type_dict
=
{
'paddings'
:
0
,
...
...
tools/python/modeltools/mobilenet/converter_mobilenet.py
浏览文件 @
6aec2006
# coding=utf-8
import
json
import
os
...
...
@@ -12,13 +13,25 @@ def load_mdl(mdl_json_path):
return
json
.
load
(
f
)
def
create_if_not_exit
(
target_dir
):
if
os
.
path
.
exists
(
target_dir
):
shutil
.
rmtree
(
target_dir
)
os
.
makedirs
(
target_dir
,
0777
)
class
Converter
:
'convert mdlmodel to fluidmodel'
def
__init__
(
self
,
base_dir
,
mdl_json_path
):
print
'base_dir: '
+
base_dir
self
.
mdl_json_path
=
base_dir
+
mdl_json_path
self
.
base_dir
=
base_dir
print
mdl_json_path
self
.
source_weights_dir
=
self
.
base_dir
+
'datas/sourcemodels/source_weights/'
self
.
target_weight_dir
=
self
.
base_dir
+
'datas/target/target_weights/'
create_if_not_exit
(
self
.
target_weight_dir
)
self
.
mdl_json
=
load_mdl
(
self
.
mdl_json_path
)
self
.
program_desc
=
framework_pb2
.
ProgramDesc
()
self
.
weight_list_
=
[]
...
...
@@ -41,16 +54,18 @@ class Converter:
print
'convert end.....'
desc_serialize_to_string
=
self
.
program_desc
.
SerializeToString
()
outputmodel_
=
self
.
base_dir
+
'datas/target/outputmodel/'
if
os
.
path
.
exists
(
outputmodel_
):
shutil
.
rmtree
(
outputmodel_
)
os
.
makedirs
(
outputmodel_
,
0777
)
# todo copy weight files
# if os.path.exists(outputmodel_):
# shutil.rmtree(outputmodel_)
# shutil.copytree('yolo/datas/multiobjects/float32s_nchw_with_head/', 'mobilenet/datas/target/outputmodel/')
outputmodel_dir
=
self
.
base_dir
+
'datas/target/mobilenet_classfication/'
if
os
.
path
.
exists
(
outputmodel_dir
):
shutil
.
rmtree
(
outputmodel_dir
)
os
.
makedirs
(
outputmodel_dir
,
0777
)
f
=
open
(
outputmodel_
+
"__model__"
,
"wb"
)
if
os
.
path
.
exists
(
outputmodel_dir
):
shutil
.
rmtree
(
outputmodel_dir
)
# create_if_not_exit(outputmodel_dir)
shutil
.
copytree
(
self
.
target_weight_dir
,
outputmodel_dir
)
f
=
open
(
outputmodel_dir
+
"__model__"
,
"wb"
)
f
.
write
(
desc_serialize_to_string
)
f
.
close
()
...
...
@@ -63,26 +78,30 @@ class Converter:
layers_
=
self
.
mdl_json
[
'layer'
]
for
layer
in
layers_
:
desc_ops_add
=
block_desc
.
ops
.
add
()
# print layer
# for i in layer:
# print i
if
'name'
in
layer
:
l_name
=
layer
[
'name'
]
if
'type'
in
layer
:
self
.
package_ops_type
(
desc_ops_add
,
layer
)
if
layer
[
'type'
]
==
'SoftmaxLayer'
:
pass
else
:
desc_ops_add
=
block_desc
.
ops
.
add
()
# print layer
# for i in layer:
# print i
if
'name'
in
layer
:
l_name
=
layer
[
'name'
]
if
'type'
in
layer
:
self
.
package_ops_type
(
desc_ops_add
,
layer
)
if
'weight'
in
layer
:
self
.
package_ops_weight2inputs
(
desc_ops_add
,
layer
)
if
'weight'
in
layer
:
self
.
package_ops_weight2inputs
(
desc_ops_add
,
layer
)
if
'output'
in
layer
:
self
.
package_ops_outputs
(
desc_ops_add
,
layer
)
if
'output'
in
layer
:
self
.
package_ops_outputs
(
desc_ops_add
,
layer
)
if
'input'
in
layer
:
self
.
package_ops_inputs
(
desc_ops_add
,
layer
)
if
'input'
in
layer
:
self
.
package_ops_inputs
(
desc_ops_add
,
layer
)
self
.
package_ops_attrs
(
desc_ops_add
,
layer
)
self
.
package_ops_attrs
(
desc_ops_add
,
layer
)
self
.
add_op_fetch
(
block_desc
)
...
...
@@ -105,7 +124,8 @@ class Converter:
desc_ops_add
=
block_desc
.
ops
.
add
()
inputs_add
=
desc_ops_add
.
inputs
.
add
()
inputs_add
.
parameter
=
'X'
inputs_add
.
arguments
.
append
(
'conv_pred_87'
)
# todo pick last layer --> op output
inputs_add
.
arguments
.
append
(
'fc7'
)
desc_ops_add
.
type
=
'fetch'
outputs_add
=
desc_ops_add
.
outputs
.
add
()
outputs_add
.
parameter
=
'Out'
...
...
@@ -129,6 +149,128 @@ class Converter:
# boolean
attrs_add
.
type
=
6
attrs_add
.
b
=
0
elif
desc_ops_add
.
type
==
types
.
op_fluid_pooling
:
Converter
.
pack_pooling_attr
(
desc_ops_add
,
layer
)
pass
elif
desc_ops_add
.
type
==
types
.
op_fluid_softmax
:
pass
@
staticmethod
def
pack_pooling_attr
(
desc_ops_add
,
layer
):
print
layer
l_params
=
layer
[
'param'
]
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'use_mkldnn'
# boolean
attrs_add
.
type
=
6
attrs_add
.
b
=
0
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'use_cudnn'
# boolean
attrs_add
.
type
=
6
attrs_add
.
b
=
1
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'paddings'
# ints
attrs_add
.
type
=
3
attrs_add
.
ints
.
append
(
0
)
attrs_add
.
ints
.
append
(
0
)
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'strides'
# ints
attrs_add
.
type
=
3
attrs_add
.
ints
.
append
(
1
)
attrs_add
.
ints
.
append
(
1
)
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'global_pooling'
# boolean
attrs_add
.
type
=
6
attrs_add
.
b
=
(
l_params
[
types
.
pool2d_attrs_dict
.
get
(
'global_pooling'
)])
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'pooling_type'
# 2-->STRING
attrs_add
.
type
=
2
# 注意这里 avg but mdl is ave
attrs_add
.
s
=
l_params
[
types
.
pool2d_attrs_dict
.
get
(
'pooling_type'
)]
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'ceil_mode'
# boolean
attrs_add
.
type
=
6
attrs_add
.
b
=
1
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'ksize'
# ints
attrs_add
.
type
=
3
attrs_add
.
ints
.
append
(
7
)
attrs_add
.
ints
.
append
(
7
)
# type: "pool2d"
# attrs
# {
# name: "use_mkldnn"
# type: BOOLEAN
# b: false
# }
# attrs
# {
# name: "ceil_mode"
# type: BOOLEAN
# b: true
# }
# attrs
# {
# name: "use_cudnn"
# type: BOOLEAN
# b: true
# }
# attrs
# {
# name: "paddings"
# type: INTS
# ints: 0
# ints: 0
# }
# attrs
# {
# name: "strides"
# type: INTS
# ints: 1
# ints: 1
# }
# attrs
# {
# name: "global_pooling"
# type: BOOLEAN
# b: false
# }
# attrs
# {
# name: "data_format"
# type: STRING
# s: "AnyLayout"
# }
# attrs
# {
# name: "ksize"
# type: INTS
# ints: 7
# ints: 7
# }
# attrs
# {
# name: "pooling_type"
# type: STRING
# s: "avg"
# }
# is_target: false
@
staticmethod
def
pack_fusion_conv_add_attr
(
desc_ops_add
,
layer
):
...
...
@@ -181,6 +323,13 @@ class Converter:
attrs_add
.
ints
.
append
(
l_params
[
types
.
fusion_conv_add_attrs_dict
.
get
(
'paddings'
)])
attrs_add
.
ints
.
append
(
l_params
[
types
.
fusion_conv_add_attrs_dict
.
get
(
'paddings'
)])
# attrs_add = desc_ops_add.attrs.add()
# attrs_add.name = 'paddings'
# # ints
# attrs_add.type = 3
# attrs_add.ints.append(0)
# attrs_add.ints.append(0)
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'strides'
# ints
...
...
@@ -188,6 +337,13 @@ class Converter:
attrs_add
.
ints
.
append
(
l_params
[
types
.
fusion_conv_add_attrs_dict
.
get
(
'strides'
)])
attrs_add
.
ints
.
append
(
l_params
[
types
.
fusion_conv_add_attrs_dict
.
get
(
'strides'
)])
# attrs_add = desc_ops_add.attrs.add()
# attrs_add.name = 'strides'
# # ints
# attrs_add.type = 3
# attrs_add.ints.append(6)
# attrs_add.ints.append(6)
attrs_add
=
desc_ops_add
.
attrs
.
add
()
attrs_add
.
name
=
'groups'
# int
...
...
@@ -232,8 +388,8 @@ class Converter:
# print o
outputs_add
=
desc_ops_add
.
outputs
.
add
()
dict
=
types
.
op_io_dict
.
get
(
desc_ops_add
.
type
)
print
'desc_ops_add.type: '
+
desc_ops_add
.
type
print
dict
#
print 'desc_ops_add.type: ' + desc_ops_add.type
#
print dict
outputs_add
.
parameter
=
dict
.
get
(
types
.
mdl_outputs_key
)
outputs_add
.
arguments
.
append
(
o
)
...
...
@@ -305,7 +461,7 @@ class Converter:
# issues in mdl model filter swich n and c
if
j
in
self
.
deepwise_weight_list_
and
len
(
dims_of_matrix
)
==
4
:
print
j
print
"deep wise issue fit: "
+
j
tensor
.
dims
.
append
(
dims_of_matrix
[
1
])
tensor
.
dims
.
append
(
dims_of_matrix
[
0
])
tensor
.
dims
.
append
(
dims_of_matrix
[
2
])
...
...
@@ -320,6 +476,12 @@ class Converter:
vars_add
.
persistable
=
1
dims_size
=
len
(
dims_of_matrix
)
# print dims_size
# print 'weight name : ' + j
Swichter
().
copy_add_head
(
self
.
source_weights_dir
+
j
+
'.bin'
,
self
.
target_weight_dir
+
j
)
# if dims_size == 4:
# # convert weight from nhwc to nchw
# Swichter().nhwc2nchw_one_slice_add_head(
...
...
@@ -341,7 +503,7 @@ class Converter:
vars_add
.
persistable
=
0
mdl_path
=
"datas/sourcemodels/
cls231_0802
/mobileNetModel.json"
mdl_path
=
"datas/sourcemodels/
source_profile
/mobileNetModel.json"
base_dir
=
"/Users/xiebaiyuan/PaddleProject/paddle-mobile/tools/python/modeltools/mobilenet/"
converter
=
Converter
(
base_dir
,
mdl_path
)
converter
.
convert
()
tools/python/modeltools/mobilenet/swicher.py
浏览文件 @
6aec2006
import
os
import
shutil
from
array
import
array
...
...
@@ -58,7 +60,7 @@ class Swichter:
to_file
=
open
(
to_file_name
,
"wb"
)
tmp
=
tmp_file
.
read
()
head
=
self
.
read_head
(
'yolo/datas/yolo/
conv1_biases
'
)
head
=
self
.
read_head
(
'yolo/datas/yolo/
head
'
)
to_file
.
write
(
head
)
to_file
.
write
(
tmp
)
tmp_file
.
close
()
...
...
@@ -72,12 +74,14 @@ class Swichter:
# print read
return
read
def
copy_add_head
(
self
,
from_file_name
,
to_file_name
,
tmp_file_name
):
def
copy_add_head
(
self
,
from_file_name
,
to_file_name
):
from_file
=
open
(
from_file_name
,
"rb"
)
to_file
=
open
(
to_file_name
,
"wb"
)
# tmp_file = open(tmp_file_name, "wb")
head
=
self
.
read_head
(
'yolo/datas/yolo/conv1_biases'
)
head
=
self
.
read_head
(
'/Users/xiebaiyuan/PaddleProject/paddle-mobile/tools/python/modeltools/mobilenet/datas/sourcemodels/head/head'
)
to_file
.
write
(
head
)
to_file
.
write
(
from_file
.
read
())
from_file
.
close
()
...
...
@@ -96,7 +100,7 @@ class Swichter:
to_file
=
open
(
to_file_name
,
"wb"
)
# tmp_file = open(tmp_file_name, "wb")
head
=
self
.
read_head
(
'yolo/datas/yolo/
conv1_biases
'
)
head
=
self
.
read_head
(
'yolo/datas/yolo/
head
'
)
to_file
.
write
(
head
)
to_file
.
write
(
read
)
from_file
.
close
()
...
...
@@ -110,6 +114,6 @@ class Swichter:
# 32,
# 3, 3, 3)
# Swichter().read_head('/Users/xiebaiyuan/PaddleProject/paddle-mobile/python/tools/modeltools/yolo/
conv1_biases
')
# Swichter().read_head('/Users/xiebaiyuan/PaddleProject/paddle-mobile/python/tools/modeltools/yolo/
head
')
# Swichter().copy_add_head('datas/model.0.0.weight', 'datas/conv1_0', '')
tools/python/modeltools/yolo/swicher.py
浏览文件 @
6aec2006
...
...
@@ -58,7 +58,7 @@ class Swichter:
to_file
=
open
(
to_file_name
,
"wb"
)
tmp
=
tmp_file
.
read
()
head
=
self
.
read_head
(
'yolo/datas/yolo/
conv1_biases
'
)
head
=
self
.
read_head
(
'yolo/datas/yolo/
head
'
)
to_file
.
write
(
head
)
to_file
.
write
(
tmp
)
tmp_file
.
close
()
...
...
@@ -77,7 +77,7 @@ class Swichter:
to_file
=
open
(
to_file_name
,
"wb"
)
# tmp_file = open(tmp_file_name, "wb")
head
=
self
.
read_head
(
'yolo/datas/yolo/
conv1_biases
'
)
head
=
self
.
read_head
(
'yolo/datas/yolo/
head
'
)
to_file
.
write
(
head
)
to_file
.
write
(
from_file
.
read
())
from_file
.
close
()
...
...
@@ -96,7 +96,7 @@ class Swichter:
to_file
=
open
(
to_file_name
,
"wb"
)
# tmp_file = open(tmp_file_name, "wb")
head
=
self
.
read_head
(
'yolo/datas/yolo/
conv1_biases
'
)
head
=
self
.
read_head
(
'yolo/datas/yolo/
head
'
)
to_file
.
write
(
head
)
to_file
.
write
(
read
)
from_file
.
close
()
...
...
@@ -110,6 +110,6 @@ class Swichter:
# 32,
# 3, 3, 3)
# Swichter().read_head('/Users/xiebaiyuan/PaddleProject/paddle-mobile/python/tools/modeltools/yolo/
conv1_biases
')
# Swichter().read_head('/Users/xiebaiyuan/PaddleProject/paddle-mobile/python/tools/modeltools/yolo/
head
')
# Swichter().copy_add_head('datas/model.0.0.weight', 'datas/conv1_0', '')
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录