Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
3513935f
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
3513935f
编写于
5月 10, 2017
作者:
D
dangqingqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine the annotation.
上级
e3fd0d56
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
16 deletion
+14
-16
python/paddle/v2/image.py
python/paddle/v2/image.py
+14
-16
未找到文件。
python/paddle/v2/image.py
浏览文件 @
3513935f
...
@@ -11,22 +11,20 @@ __all__ = [
...
@@ -11,22 +11,20 @@ __all__ = [
"left_right_flip"
,
"simple_transform"
,
"load_and_transform"
"left_right_flip"
,
"simple_transform"
,
"load_and_transform"
]
]
"""
"""
This file contains some common interface for image preprocess.
This file contains some common interface
s
for image preprocess.
Many users are confused about the image layout. We introduce
Many users are confused about the image layout. We introduce
the image layout
firstly
.
the image layout
as follows
.
- CHW Layout
- CHW Layout
- The abbreviations: C=channel, H=Height, W=Width
- The abbreviations: C=channel, H=Height, W=Width
- The default image layout is HWC opened by cv2 or PIL.
- The default layout of image opened by cv2 or PIL is HWC.
PaddlePaddle only support the image layout with CHW.
PaddlePaddle only supports the CHW layout. And CHW is simply
CHW is simply a transpose of HWC. It must transpose
a transpose of HWC. It must transpose the input image.
the input image.
- Color format: RGB or BGR
- Color format: RGB or BGR
OpenCV use BGR color format. PIL use RGB color format. Both
OpenCV use BGR color format. PIL use RGB color format. Both
formats can be used for training. But it must be noted that,
formats can be used for training. Noted that, the format should
the format should be keep consistent between the training and
be keep consistent between the training and inference peroid.
inference peroid.
"""
"""
...
@@ -85,8 +83,8 @@ def resize_short(im, size):
...
@@ -85,8 +83,8 @@ def resize_short(im, size):
def
to_chw
(
im
,
order
=
(
2
,
0
,
1
)):
def
to_chw
(
im
,
order
=
(
2
,
0
,
1
)):
"""
"""
Transpose the input image order. The image layout is HWC format
Transpose the input image order. The image layout is HWC format
opened by cv2 or PIL. Transpose
d the input image to CHW layouts
opened by cv2 or PIL. Transpose
the input image to CHW layout
by
order (2,0,1).
according the
order (2,0,1).
Example usage:
Example usage:
...
@@ -116,7 +114,7 @@ def center_crop(im, size, is_color=True):
...
@@ -116,7 +114,7 @@ def center_crop(im, size, is_color=True):
:param im: the input image with HWC layout.
:param im: the input image with HWC layout.
:type im: ndarray
:type im: ndarray
:param size: the cropping size
:param size: the cropping size
.
:type size: int
:type size: int
:param is_color: whether the image is color or not.
:param is_color: whether the image is color or not.
:type is_color: bool
:type is_color: bool
...
@@ -143,7 +141,7 @@ def random_crop(im, size, is_color=True):
...
@@ -143,7 +141,7 @@ def random_crop(im, size, is_color=True):
:param im: the input image with HWC layout.
:param im: the input image with HWC layout.
:type im: ndarray
:type im: ndarray
:param size: the cropping size
:param size: the cropping size
.
:type size: int
:type size: int
:param is_color: whether the image is color or not.
:param is_color: whether the image is color or not.
:type is_color: bool
:type is_color: bool
...
@@ -180,7 +178,7 @@ def left_right_flip(im):
...
@@ -180,7 +178,7 @@ def left_right_flip(im):
def
simple_transform
(
im
,
resize_size
,
crop_size
,
is_train
,
is_color
=
True
):
def
simple_transform
(
im
,
resize_size
,
crop_size
,
is_train
,
is_color
=
True
):
"""
"""
Simply data argumentation for train
g. These operations includes
Simply data argumentation for train
ing. These operations include
resizing, croping and flipping.
resizing, croping and flipping.
Example usage:
Example usage:
...
@@ -216,8 +214,8 @@ def load_and_transform(filename,
...
@@ -216,8 +214,8 @@ def load_and_transform(filename,
is_color
=
True
):
is_color
=
True
):
"""
"""
Load image from the input file `filename` and transform image for
Load image from the input file `filename` and transform image for
data argumentation. Please refer the `simple_transform` interface
data argumentation. Please refer t
o t
he `simple_transform` interface
for the transform operation.
for the transform operation
s
.
Example usage:
Example usage:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录