Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
76ee482e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
76ee482e
编写于
8月 10, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cv2 issues
上级
6dc07e7f
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
23 addition
and
6 deletion
+23
-6
python/paddle/dataset/image.py
python/paddle/dataset/image.py
+15
-4
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+5
-0
python/paddle/reader/decorator.py
python/paddle/reader/decorator.py
+3
-2
未找到文件。
python/paddle/dataset/image.py
浏览文件 @
76ee482e
...
...
@@ -33,6 +33,11 @@ import numpy as np
try
:
import
cv2
except
ImportError
:
import
sys
sys
.
stderr
.
write
(
'''Warning with paddle image module: opencv-python should be imported,
or paddle image module could NOT work; please install opencv-python first.'''
)
cv2
=
None
import
os
import
tarfile
...
...
@@ -126,6 +131,8 @@ def load_image_bytes(bytes, is_color=True):
load and return a gray image.
:type is_color: bool
"""
assert
cv2
is
not
None
flag
=
1
if
is_color
else
0
file_bytes
=
np
.
asarray
(
bytearray
(
bytes
),
dtype
=
np
.
uint8
)
img
=
cv2
.
imdecode
(
file_bytes
,
flag
)
...
...
@@ -149,6 +156,8 @@ def load_image(file, is_color=True):
load and return a gray image.
:type is_color: bool
"""
assert
cv2
is
not
None
# cv2.IMAGE_COLOR for OpenCV3
# cv2.CV_LOAD_IMAGE_COLOR for older OpenCV Version
# cv2.IMAGE_GRAYSCALE for OpenCV3
...
...
@@ -176,12 +185,14 @@ def resize_short(im, size):
:param size: the shorter edge size of image after resizing.
:type size: int
"""
assert
cv2
is
not
None
h
,
w
=
im
.
shape
[:
2
]
h_new
,
w_new
=
size
,
size
if
h
>
w
:
h_new
=
size
*
h
/
w
h_new
=
size
*
h
/
/
w
else
:
w_new
=
size
*
w
/
h
w_new
=
size
*
w
/
/
h
im
=
cv2
.
resize
(
im
,
(
h_new
,
w_new
),
interpolation
=
cv2
.
INTER_CUBIC
)
return
im
...
...
@@ -228,8 +239,8 @@ def center_crop(im, size, is_color=True):
:type is_color: bool
"""
h
,
w
=
im
.
shape
[:
2
]
h_start
=
(
h
-
size
)
/
2
w_start
=
(
w
-
size
)
/
2
h_start
=
(
h
-
size
)
/
/
2
w_start
=
(
w
-
size
)
/
/
2
h_end
,
w_end
=
h_start
+
size
,
w_start
+
size
if
is_color
:
im
=
im
[
h_start
:
h_end
,
w_start
:
w_end
,
:]
...
...
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
76ee482e
...
...
@@ -362,9 +362,14 @@ class OpTest(unittest.TestCase):
def
check_output_customized
(
self
,
checker
):
places
=
self
.
_get_places
()
import
sys
print
(
'places'
,
places
)
for
place
in
places
:
outs
=
self
.
calc_output
(
place
)
outs
=
[
np
.
array
(
out
)
for
out
in
outs
]
import
sys
print
(
'outs'
,
outs
)
sys
.
stdout
.
flush
()
checker
(
outs
)
def
__assert_is_close
(
self
,
numeric_grads
,
analytic_grads
,
names
,
...
...
python/paddle/reader/decorator.py
浏览文件 @
76ee482e
...
...
@@ -27,6 +27,7 @@ from six.moves import zip
import
itertools
import
random
import
zlib
import
paddle.fluid.compat
as
cpt
def
map_readers
(
func
,
*
readers
):
...
...
@@ -390,9 +391,9 @@ class PipeReader:
buff
=
self
.
process
.
stdout
.
read
(
self
.
bufsize
)
if
buff
:
if
self
.
file_type
==
"gzip"
:
decomp_buff
=
self
.
dec
.
decompress
(
buff
)
decomp_buff
=
cpt
.
to_literal_str
(
self
.
dec
.
decompress
(
buff
)
)
elif
self
.
file_type
==
"plain"
:
decomp_buff
=
buff
decomp_buff
=
cpt
.
to_literal_str
(
buff
)
else
:
raise
TypeError
(
"file_type %s is not allowed"
%
self
.
file_type
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录