Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
路上走着呢
X2Paddle
提交
05bb5a0c
X
X2Paddle
项目概览
路上走着呢
/
X2Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / X2Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
05bb5a0c
编写于
7月 07, 2020
作者:
C
Channingss
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'paddle/develop' into develop
上级
1c79e067
36ee5842
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
13 deletion
+72
-13
op_list.md
op_list.md
+2
-2
x2paddle/op_mapper/tf_op_mapper_nhwc.py
x2paddle/op_mapper/tf_op_mapper_nhwc.py
+67
-9
x2paddle_model_zoo.md
x2paddle_model_zoo.md
+3
-2
未找到文件。
op_list.md
浏览文件 @
05bb5a0c
# X2Paddle支持OP列表
> 目前X2Paddle支持
4
0+的TensorFlow OP,30+的Caffe Layer,覆盖了大部分CV分类模型常用的操作。我们在如下列表中给出了目前X2Paddle支持的全部OP。
> 目前X2Paddle支持
5
0+的TensorFlow OP,30+的Caffe Layer,覆盖了大部分CV分类模型常用的操作。我们在如下列表中给出了目前X2Paddle支持的全部OP。
**注:**
目前,部分OP暂未支持,如您在转换过程中出现OP不支持的情况,可自行添加或反馈给我们。欢迎通过
[
ISSUE反馈
](
https://github.com/PaddlePaddle/X2Paddle/issues/new
)
的方式告知我们(模型名,代码实现或模型获取方式),我们会及时跟进:)
...
...
@@ -20,7 +20,7 @@
| 41 | Cast | 42 | Split | 43 | Squeeze | 44 | ResizeNearestNeighbor |
| 45 | Softmax | 46 | Range | 47 | ConcatV2 | 48 | MirrorPad |
| 49 | Identity | 50 | GreaterEqual | 51 | StopGradient | 52 | Minimum |
| 53 | RadnomUniform |
| | | | |
|
| 53 | RadnomUniform |
54 | Fill | 55 | Floor | 56 | DepthToSpace
|
## Caffe
...
...
x2paddle/op_mapper/tf_op_mapper_nhwc.py
浏览文件 @
05bb5a0c
...
...
@@ -46,7 +46,8 @@ class TFOpMapperNHWC(OpMapper):
'Softplus'
:
[
'softplus'
],
'LeakyRelu'
:
[
'leaky_relu'
,
{
'alpha'
:
'alpha'
}]
}],
'Floor'
:
[
'floor'
]
}
elementwise_ops
=
{
'Add'
:
'elementwise_add'
,
...
...
@@ -54,6 +55,7 @@ class TFOpMapperNHWC(OpMapper):
'RealDiv'
:
'elementwise_div'
,
'Sub'
:
'elementwise_sub'
,
'Maximum'
:
'elementwise_max'
,
'Minimum'
:
'elementwise_min'
,
'Mul'
:
'elementwise_mul'
,
'FloorDiv'
:
'elementwise_floordiv'
}
...
...
@@ -202,6 +204,52 @@ class TFOpMapperNHWC(OpMapper):
node
.
fluid_code
.
add_layer
(
"transpose"
,
inputs
=
input
,
output
=
node
,
param_attr
=
attr
)
def
Fill
(
self
,
node
):
dims
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
input_value
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
1
],
copy
=
True
)
assert
input_value
.
layer_type
==
"Const"
,
"Value of fill OP should be Const"
self
.
add_omit_nodes
(
input_value
.
layer_name
,
node
.
layer_name
)
input_value
=
input_value
.
value
input_dtype
=
string
(
input_value
.
dtype
)
attr
=
{
'value'
:
input_value
,
'dtype'
:
input_dtype
}
node
.
fluid_code
.
add_layer
(
"fill_constant"
,
inputs
=
dims
,
output
=
node
,
param_attr
=
attr
)
def
DepthToSpace
(
self
,
node
):
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
block_size
=
node
.
get_attr
(
"block_size"
)
data_format
=
node
.
get_attr
(
"data_format"
).
decode
()
if
data_format
==
"NHWC"
:
attr
=
{
"perm"
:
[
0
,
3
,
1
,
2
]}
node
.
fluid_code
.
add_layer
(
"transpose"
,
inputs
=
input
,
output
=
input
,
param_attr
=
attr
)
n
,
h
,
w
,
c
=
input
.
out_shapes
[
0
]
attr
=
{
'shape'
:
[
0
,
block_size
*
block_size
,
-
1
,
h
,
w
]}
node
.
fluid_code
.
add_layer
(
"reshape"
,
inputs
=
input
,
output
=
input
,
param_attr
=
attr
)
attr
=
{
'perm'
:
[
0
,
2
,
1
,
3
,
4
]}
node
.
fluid_code
.
add_layer
(
"transpose"
,
inputs
=
input
,
output
=
input
,
param_attr
=
attr
)
attr
=
{
'shape'
:
[
0
,
c
,
h
,
w
]}
node
.
fluid_code
.
add_layer
(
"reshape"
,
inputs
=
input
,
output
=
input
,
param_attr
=
attr
)
attr
=
{
'upscale_factor'
:
block_size
}
node
.
fluid_code
.
add_layer
(
"pixel_shuffle"
,
inputs
=
input
,
output
=
node
,
param_attr
=
attr
)
if
data_format
==
"NHWC"
:
attr
=
{
"perm"
:
[
0
,
2
,
3
,
1
]}
node
.
fluid_code
.
add_layer
(
"transpose"
,
inputs
=
node
,
output
=
node
,
param_attr
=
attr
)
def
MaxPool
(
self
,
node
):
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
...
...
@@ -236,6 +284,7 @@ class TFOpMapperNHWC(OpMapper):
def
Conv2D
(
self
,
node
):
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
kernel
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
1
],
copy
=
True
)
self
.
add_omit_nodes
(
kernel
.
layer_name
,
node
.
layer_name
)
k_size
=
kernel
.
out_shapes
[
0
]
strides
=
node
.
get_attr
(
"strides"
)
...
...
@@ -245,10 +294,17 @@ class TFOpMapperNHWC(OpMapper):
channel_first
=
data_format
==
"NCHW"
if
kernel
.
layer_type
==
'Const'
:
self
.
add_omit_nodes
(
kernel
.
layer_name
,
node
.
layer_name
)
kernel_value
=
kernel
.
value
self
.
weights
[
kernel
.
layer_name
.
replace
(
'/'
,
'_'
)]
=
numpy
.
transpose
(
kernel_value
,
(
3
,
2
,
0
,
1
))
kernel_weight_name
=
kernel
.
layer_name
.
replace
(
'/'
,
'_'
)
else
:
kernel_value
=
self
.
decoder
.
infer_tensor
(
kernel
)
if
kernel
.
layer_type
==
'Split'
:
kernel_weight_name
=
"{}_{}_kernel"
.
format
(
node
.
layer_name
,
kernel
.
layer_name
)
else
:
kernel_weight_name
=
kernel
.
layer_name
.
replace
(
'/'
,
'_'
)
self
.
weights
[
kernel_weight_name
]
=
numpy
.
transpose
(
kernel_value
,
(
3
,
2
,
0
,
1
))
if
not
channel_first
:
strides
=
[
strides
[
i
]
for
i
in
[
0
,
3
,
1
,
2
]]
...
...
@@ -257,10 +313,9 @@ class TFOpMapperNHWC(OpMapper):
node
.
fluid_code
.
add_layer
(
"transpose"
,
inputs
=
input
,
output
=
node
,
param_attr
=
attr
)
input
=
node
attr
=
{
"bias_attr"
:
False
,
"param_attr"
:
string
(
kernel
.
layer
_name
),
"param_attr"
:
string
(
kernel
_weight
_name
),
"num_filters"
:
k_size
[
3
],
"filter_size"
:
k_size
[
0
:
2
],
"stride"
:
strides
[
2
:
4
],
...
...
@@ -700,13 +755,16 @@ class TFOpMapperNHWC(OpMapper):
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
2
],
copy
=
True
)
assert
kernel
.
layer_type
==
"Const"
,
"Kernel of Conv2DBackpropInput should be Const"
assert
out_shape
.
layer_type
==
"Const"
,
"Out_shape of Conv2DBackpropInput should be Const"
self
.
add_omit_nodes
(
kernel
.
layer_name
,
node
.
layer_name
)
out_shape
=
out_shape
.
value
.
tolist
()
self
.
add_omit_nodes
(
out_shape
.
layer_name
,
node
.
layer_name
)
if
out_shape
.
layer_type
==
"Const"
:
out_shape
=
out_shape
.
value
.
tolist
()
else
:
out_shape
=
self
.
decoder
.
infer_shape_tensor
(
out_shape
,
node
.
out_shapes
[
0
])
in_shape
=
input
.
out_shapes
[
0
]
if
in_shape
.
count
(
-
1
)
>
2
:
in_shape
=
self
.
decoder
.
infer_tensor
(
input
).
shape
...
...
x2paddle_model_zoo.md
浏览文件 @
05bb5a0c
# X2Paddle模型测试库
> 目前X2Paddle支持
4
0+的TensorFlow OP,40+的Caffe Layer,覆盖了大部分CV分类模型常用的操作。我们在如下模型列表中测试了X2Paddle的转换。
> 目前X2Paddle支持
5
0+的TensorFlow OP,40+的Caffe Layer,覆盖了大部分CV分类模型常用的操作。我们在如下模型列表中测试了X2Paddle的转换。
**注:**
受限于不同框架的差异,部分模型可能会存在目前无法转换的情况,如TensorFlow中包含控制流的模型,NLP模型等。对于CV常见的模型,如若您发现无法转换或转换失败,存在较大diff等问题,欢迎通过
[
ISSUE反馈
](
https://github.com/PaddlePaddle/X2Paddle/issues/new
)
的方式告知我们(模型名,代码实现或模型获取方式),我们会及时跟进:)
...
...
@@ -22,7 +22,8 @@
| UNet |
[
code1
](
https://github.com/jakeret/tf_unet
)
/
[
code2
](
https://github.com/lyatdawn/Unet-Tensorflow
)
|-|
|MTCNN |
[
code
](
https://github.com/AITTSMD/MTCNN-Tensorflow
)
|-|
|YOLO-V3|
[
code
](
https://github.com/YunYang1994/tensorflow-yolov3
)
| 转换需要关闭NHWC->NCHW的优化,见
[
文档Q2
](
FAQ.md
)
|
|Inception_ResNet_V2|
[
code
](
https://github.com/tensorflow/models/tree/master/research/slim/nets
)
| - |
| FALSR |
[
code
](
https://github.com/xiaomi-automl/FALSR
)
| - |
| DCSCN |
[
code
](
https://modelzoo.co/model/dcscn-super-resolution
)
| - |
## Caffe
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录