Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
69fffae6
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
69fffae6
编写于
8月 27, 2018
作者:
X
Xin Pan
提交者:
GitHub
8月 27, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12917 from JiabinYang/check_v2_release
fix bug to avoid warning once import paddle.fluid
上级
ceef49a6
44240d4d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
15 addition
and
8 deletion
+15
-8
python/paddle/dataset/image.py
python/paddle/dataset/image.py
+15
-8
未找到文件。
python/paddle/dataset/image.py
浏览文件 @
69fffae6
...
@@ -36,11 +36,6 @@ import numpy as np
...
@@ -36,11 +36,6 @@ import numpy as np
try
:
try
:
import
cv2
import
cv2
except
ImportError
:
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
cv2
=
None
import
os
import
os
import
tarfile
import
tarfile
...
@@ -53,6 +48,18 @@ __all__ = [
...
@@ -53,6 +48,18 @@ __all__ = [
]
]
def
_check_cv2
():
if
cv2
is
None
:
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.'''
)
return
False
else
:
return
True
def
batch_images_from_tar
(
data_file
,
def
batch_images_from_tar
(
data_file
,
dataset_name
,
dataset_name
,
img2label
,
img2label
,
...
@@ -134,7 +141,7 @@ def load_image_bytes(bytes, is_color=True):
...
@@ -134,7 +141,7 @@ def load_image_bytes(bytes, is_color=True):
load and return a gray image.
load and return a gray image.
:type is_color: bool
:type is_color: bool
"""
"""
assert
cv2
is
not
Non
e
assert
_check_cv2
()
is
Tru
e
flag
=
1
if
is_color
else
0
flag
=
1
if
is_color
else
0
file_bytes
=
np
.
asarray
(
bytearray
(
bytes
),
dtype
=
np
.
uint8
)
file_bytes
=
np
.
asarray
(
bytearray
(
bytes
),
dtype
=
np
.
uint8
)
...
@@ -159,7 +166,7 @@ def load_image(file, is_color=True):
...
@@ -159,7 +166,7 @@ def load_image(file, is_color=True):
load and return a gray image.
load and return a gray image.
:type is_color: bool
:type is_color: bool
"""
"""
assert
cv2
is
not
Non
e
assert
_check_cv2
()
is
Tru
e
# cv2.IMAGE_COLOR for OpenCV3
# cv2.IMAGE_COLOR for OpenCV3
# cv2.CV_LOAD_IMAGE_COLOR for older OpenCV Version
# cv2.CV_LOAD_IMAGE_COLOR for older OpenCV Version
...
@@ -188,7 +195,7 @@ def resize_short(im, size):
...
@@ -188,7 +195,7 @@ def resize_short(im, size):
:param size: the shorter edge size of image after resizing.
:param size: the shorter edge size of image after resizing.
:type size: int
:type size: int
"""
"""
assert
cv2
is
not
Non
e
assert
_check_cv2
()
is
Tru
e
h
,
w
=
im
.
shape
[:
2
]
h
,
w
=
im
.
shape
[:
2
]
h_new
,
w_new
=
size
,
size
h_new
,
w_new
=
size
,
size
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录