Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
ad9d219a
M
models
项目概览
PaddlePaddle
/
models
1 年多 前同步成功
通知
225
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看板
未验证
提交
ad9d219a
编写于
4月 24, 2019
作者:
W
whs
提交者:
GitHub
4月 24, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename core.LoDTensor to fluid.LoDTensor in ocr, gan and icnet (#2141)
上级
0a0021f3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
24 deletion
+20
-24
PaddleCV/gan/cycle_gan/infer.py
PaddleCV/gan/cycle_gan/infer.py
+1
-2
PaddleCV/gan/cycle_gan/train.py
PaddleCV/gan/cycle_gan/train.py
+4
-5
PaddleCV/icnet/infer.py
PaddleCV/icnet/infer.py
+1
-1
PaddleCV/icnet/utils.py
PaddleCV/icnet/utils.py
+10
-11
PaddleCV/ocr_recognition/utility.py
PaddleCV/ocr_recognition/utility.py
+4
-5
未找到文件。
PaddleCV/gan/cycle_gan/infer.py
浏览文件 @
ad9d219a
...
@@ -2,7 +2,6 @@ import argparse
...
@@ -2,7 +2,6 @@ import argparse
import
functools
import
functools
import
os
import
os
from
PIL
import
Image
from
PIL
import
Image
from
paddle.fluid
import
core
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
paddle
import
paddle
import
numpy
as
np
import
numpy
as
np
...
@@ -51,7 +50,7 @@ def infer(args):
...
@@ -51,7 +50,7 @@ def infer(args):
if
len
(
image
.
shape
)
!=
3
:
if
len
(
image
.
shape
)
!=
3
:
continue
continue
data
=
image
.
transpose
([
2
,
0
,
1
])[
np
.
newaxis
,
:].
astype
(
"float32"
)
data
=
image
.
transpose
([
2
,
0
,
1
])[
np
.
newaxis
,
:].
astype
(
"float32"
)
tensor
=
core
.
LoDTensor
()
tensor
=
fluid
.
LoDTensor
()
tensor
.
set
(
data
,
place
)
tensor
.
set
(
data
,
place
)
fake_temp
=
exe
.
run
(
fetch_list
=
[
fake
.
name
],
feed
=
{
"input"
:
tensor
})
fake_temp
=
exe
.
run
(
fetch_list
=
[
fake
.
name
],
feed
=
{
"input"
:
tensor
})
...
...
PaddleCV/gan/cycle_gan/train.py
浏览文件 @
ad9d219a
...
@@ -12,7 +12,6 @@ import numpy as np
...
@@ -12,7 +12,6 @@ import numpy as np
from
scipy.misc
import
imsave
from
scipy.misc
import
imsave
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
paddle.fluid.profiler
as
profiler
import
paddle.fluid.profiler
as
profiler
from
paddle.fluid
import
core
import
data_reader
import
data_reader
from
utility
import
add_arguments
,
print_arguments
,
ImagePool
from
utility
import
add_arguments
,
print_arguments
,
ImagePool
from
trainer
import
*
from
trainer
import
*
...
@@ -82,8 +81,8 @@ def train(args):
...
@@ -82,8 +81,8 @@ def train(args):
for
data_A
,
data_B
in
zip
(
A_test_reader
(),
B_test_reader
()):
for
data_A
,
data_B
in
zip
(
A_test_reader
(),
B_test_reader
()):
A_name
=
data_A
[
1
]
A_name
=
data_A
[
1
]
B_name
=
data_B
[
1
]
B_name
=
data_B
[
1
]
tensor_A
=
core
.
LoDTensor
()
tensor_A
=
fluid
.
LoDTensor
()
tensor_B
=
core
.
LoDTensor
()
tensor_B
=
fluid
.
LoDTensor
()
tensor_A
.
set
(
data_A
[
0
],
place
)
tensor_A
.
set
(
data_A
[
0
],
place
)
tensor_B
.
set
(
data_B
[
0
],
place
)
tensor_B
.
set
(
data_B
[
0
],
place
)
fake_A_temp
,
fake_B_temp
,
cyc_A_temp
,
cyc_B_temp
=
exe
.
run
(
fake_A_temp
,
fake_B_temp
,
cyc_A_temp
,
cyc_B_temp
=
exe
.
run
(
...
@@ -168,8 +167,8 @@ def train(args):
...
@@ -168,8 +167,8 @@ def train(args):
for
i
in
range
(
max_images_num
):
for
i
in
range
(
max_images_num
):
data_A
=
next
(
A_reader
)
data_A
=
next
(
A_reader
)
data_B
=
next
(
B_reader
)
data_B
=
next
(
B_reader
)
tensor_A
=
core
.
LoDTensor
()
tensor_A
=
fluid
.
LoDTensor
()
tensor_B
=
core
.
LoDTensor
()
tensor_B
=
fluid
.
LoDTensor
()
tensor_A
.
set
(
data_A
,
place
)
tensor_A
.
set
(
data_A
,
place
)
tensor_B
.
set
(
data_B
,
place
)
tensor_B
.
set
(
data_B
,
place
)
s_time
=
time
.
time
()
s_time
=
time
.
time
()
...
...
PaddleCV/icnet/infer.py
浏览文件 @
ad9d219a
...
@@ -115,7 +115,7 @@ def infer(args):
...
@@ -115,7 +115,7 @@ def infer(args):
image_file
,
is_color
=
True
).
astype
(
"float32"
)
image_file
,
is_color
=
True
).
astype
(
"float32"
)
image
-=
IMG_MEAN
image
-=
IMG_MEAN
img
=
paddle
.
dataset
.
image
.
to_chw
(
image
)[
np
.
newaxis
,
:]
img
=
paddle
.
dataset
.
image
.
to_chw
(
image
)[
np
.
newaxis
,
:]
image_t
=
fluid
.
core
.
LoDTensor
()
image_t
=
fluid
.
LoDTensor
()
image_t
.
set
(
img
,
place
)
image_t
.
set
(
img
,
place
)
result
=
exe
.
run
(
inference_program
,
result
=
exe
.
run
(
inference_program
,
feed
=
{
"image"
:
image_t
},
feed
=
{
"image"
:
image_t
},
...
...
PaddleCV/icnet/utils.py
浏览文件 @
ad9d219a
...
@@ -18,7 +18,6 @@ from __future__ import division
...
@@ -18,7 +18,6 @@ from __future__ import division
from
__future__
import
print_function
from
__future__
import
print_function
import
distutils.util
import
distutils.util
import
numpy
as
np
import
numpy
as
np
from
paddle.fluid
import
core
import
six
import
six
...
@@ -72,7 +71,7 @@ def to_lodtensor(data, place):
...
@@ -72,7 +71,7 @@ def to_lodtensor(data, place):
lod
.
append
(
cur_len
)
lod
.
append
(
cur_len
)
flattened_data
=
np
.
concatenate
(
data
,
axis
=
0
).
astype
(
"int32"
)
flattened_data
=
np
.
concatenate
(
data
,
axis
=
0
).
astype
(
"int32"
)
flattened_data
=
flattened_data
.
reshape
([
len
(
flattened_data
),
1
])
flattened_data
=
flattened_data
.
reshape
([
len
(
flattened_data
),
1
])
res
=
core
.
LoDTensor
()
res
=
fluid
.
LoDTensor
()
res
.
set
(
flattened_data
,
place
)
res
.
set
(
flattened_data
,
place
)
res
.
set_lod
([
lod
])
res
.
set_lod
([
lod
])
return
res
return
res
...
@@ -80,17 +79,17 @@ def to_lodtensor(data, place):
...
@@ -80,17 +79,17 @@ def to_lodtensor(data, place):
def
get_feeder_data
(
data
,
place
,
for_test
=
False
):
def
get_feeder_data
(
data
,
place
,
for_test
=
False
):
feed_dict
=
{}
feed_dict
=
{}
image_t
=
core
.
LoDTensor
()
image_t
=
fluid
.
LoDTensor
()
image_t
.
set
(
data
[
0
],
place
)
image_t
.
set
(
data
[
0
],
place
)
feed_dict
[
"image"
]
=
image_t
feed_dict
[
"image"
]
=
image_t
if
not
for_test
:
if
not
for_test
:
labels_sub1_t
=
core
.
LoDTensor
()
labels_sub1_t
=
fluid
.
LoDTensor
()
labels_sub2_t
=
core
.
LoDTensor
()
labels_sub2_t
=
fluid
.
LoDTensor
()
labels_sub4_t
=
core
.
LoDTensor
()
labels_sub4_t
=
fluid
.
LoDTensor
()
mask_sub1_t
=
core
.
LoDTensor
()
mask_sub1_t
=
fluid
.
LoDTensor
()
mask_sub2_t
=
core
.
LoDTensor
()
mask_sub2_t
=
fluid
.
LoDTensor
()
mask_sub4_t
=
core
.
LoDTensor
()
mask_sub4_t
=
fluid
.
LoDTensor
()
labels_sub1_t
.
set
(
data
[
1
],
place
)
labels_sub1_t
.
set
(
data
[
1
],
place
)
labels_sub2_t
.
set
(
data
[
3
],
place
)
labels_sub2_t
.
set
(
data
[
3
],
place
)
...
@@ -105,8 +104,8 @@ def get_feeder_data(data, place, for_test=False):
...
@@ -105,8 +104,8 @@ def get_feeder_data(data, place, for_test=False):
feed_dict
[
"label_sub4"
]
=
labels_sub4_t
feed_dict
[
"label_sub4"
]
=
labels_sub4_t
feed_dict
[
"mask_sub4"
]
=
mask_sub4_t
feed_dict
[
"mask_sub4"
]
=
mask_sub4_t
else
:
else
:
label_t
=
core
.
LoDTensor
()
label_t
=
fluid
.
LoDTensor
()
mask_t
=
core
.
LoDTensor
()
mask_t
=
fluid
.
LoDTensor
()
label_t
.
set
(
data
[
1
],
place
)
label_t
.
set
(
data
[
1
],
place
)
mask_t
.
set
(
data
[
2
],
place
)
mask_t
.
set
(
data
[
2
],
place
)
feed_dict
[
"label"
]
=
label_t
feed_dict
[
"label"
]
=
label_t
...
...
PaddleCV/ocr_recognition/utility.py
浏览文件 @
ad9d219a
...
@@ -18,7 +18,6 @@ from __future__ import division
...
@@ -18,7 +18,6 @@ from __future__ import division
from
__future__
import
print_function
from
__future__
import
print_function
import
distutils.util
import
distutils.util
import
numpy
as
np
import
numpy
as
np
from
paddle.fluid
import
core
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
six
import
six
...
@@ -73,14 +72,14 @@ def to_lodtensor(data, place):
...
@@ -73,14 +72,14 @@ def to_lodtensor(data, place):
lod
.
append
(
cur_len
)
lod
.
append
(
cur_len
)
flattened_data
=
np
.
concatenate
(
data
,
axis
=
0
).
astype
(
"int32"
)
flattened_data
=
np
.
concatenate
(
data
,
axis
=
0
).
astype
(
"int32"
)
flattened_data
=
flattened_data
.
reshape
([
len
(
flattened_data
),
1
])
flattened_data
=
flattened_data
.
reshape
([
len
(
flattened_data
),
1
])
res
=
core
.
LoDTensor
()
res
=
fluid
.
LoDTensor
()
res
.
set
(
flattened_data
,
place
)
res
.
set
(
flattened_data
,
place
)
res
.
set_lod
([
lod
])
res
.
set_lod
([
lod
])
return
res
return
res
def
get_ctc_feeder_data
(
data
,
place
,
need_label
=
True
):
def
get_ctc_feeder_data
(
data
,
place
,
need_label
=
True
):
pixel_tensor
=
core
.
LoDTensor
()
pixel_tensor
=
fluid
.
LoDTensor
()
pixel_data
=
None
pixel_data
=
None
pixel_data
=
np
.
concatenate
(
pixel_data
=
np
.
concatenate
(
list
(
map
(
lambda
x
:
x
[
0
][
np
.
newaxis
,
:],
data
)),
list
(
map
(
lambda
x
:
x
[
0
][
np
.
newaxis
,
:],
data
)),
...
@@ -98,7 +97,7 @@ def get_ctc_feeder_for_infer(data, place):
...
@@ -98,7 +97,7 @@ def get_ctc_feeder_for_infer(data, place):
def
get_attention_feeder_data
(
data
,
place
,
need_label
=
True
):
def
get_attention_feeder_data
(
data
,
place
,
need_label
=
True
):
pixel_tensor
=
core
.
LoDTensor
()
pixel_tensor
=
fluid
.
LoDTensor
()
pixel_data
=
None
pixel_data
=
None
pixel_data
=
np
.
concatenate
(
pixel_data
=
np
.
concatenate
(
list
(
map
(
lambda
x
:
x
[
0
][
np
.
newaxis
,
:],
data
)),
list
(
map
(
lambda
x
:
x
[
0
][
np
.
newaxis
,
:],
data
)),
...
@@ -130,7 +129,7 @@ def get_attention_feeder_for_infer(data, place):
...
@@ -130,7 +129,7 @@ def get_attention_feeder_for_infer(data, place):
init_scores
=
fluid
.
create_lod_tensor
(
init_scores_data
,
init_scores
=
fluid
.
create_lod_tensor
(
init_scores_data
,
init_recursive_seq_lens
,
place
)
init_recursive_seq_lens
,
place
)
pixel_tensor
=
core
.
LoDTensor
()
pixel_tensor
=
fluid
.
LoDTensor
()
pixel_data
=
None
pixel_data
=
None
pixel_data
=
np
.
concatenate
(
pixel_data
=
np
.
concatenate
(
list
(
map
(
lambda
x
:
x
[
0
][
np
.
newaxis
,
:],
data
)),
list
(
map
(
lambda
x
:
x
[
0
][
np
.
newaxis
,
:],
data
)),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录