Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
92d65ed4
B
book
项目概览
PaddlePaddle
/
book
通知
17
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
92d65ed4
编写于
4月 25, 2017
作者:
Q
qingqing01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
follow comments
上级
0087e3cc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
0 deletion
+26
-0
03.image_classification/README.en.md
03.image_classification/README.en.md
+6
-0
03.image_classification/README.md
03.image_classification/README.md
+4
-0
03.image_classification/index.en.html
03.image_classification/index.en.html
+6
-0
03.image_classification/index.html
03.image_classification/index.html
+4
-0
03.image_classification/train.py
03.image_classification/train.py
+6
-0
未找到文件。
03.image_classification/README.en.md
浏览文件 @
92d65ed4
...
@@ -491,7 +491,13 @@ def load_image(file):
...
@@ -491,7 +491,13 @@ def load_image(file):
im
=
Image
.
open
(
file
)
im
=
Image
.
open
(
file
)
im
=
im
.
resize
((
32
,
32
),
Image
.
ANTIALIAS
)
im
=
im
.
resize
((
32
,
32
),
Image
.
ANTIALIAS
)
im
=
np
.
array
(
im
).
astype
(
np
.
float32
)
im
=
np
.
array
(
im
).
astype
(
np
.
float32
)
# The storage order of the loaded image is W(widht),
# H(height), C(channel). PaddlePaddle requires
# the CHW order, so transpose them.
im
=
im
.
transpose
((
2
,
0
,
1
))
# CHW
im
=
im
.
transpose
((
2
,
0
,
1
))
# CHW
# In the training phase, the channel order of CIFAR
# image is B(Blue), G(green), R(Red). But PIL open
# image in RGB mode. It must swap the channel order.
im
=
im
[(
2
,
1
,
0
),:,:]
# BGR
im
=
im
[(
2
,
1
,
0
),:,:]
# BGR
im
=
im
.
flatten
()
im
=
im
.
flatten
()
im
=
im
/
255.0
im
=
im
/
255.0
...
...
03.image_classification/README.md
浏览文件 @
92d65ed4
...
@@ -483,7 +483,11 @@ def load_image(file):
...
@@ -483,7 +483,11 @@ def load_image(file):
im
=
Image
.
open
(
file
)
im
=
Image
.
open
(
file
)
im
=
im
.
resize
((
32
,
32
),
Image
.
ANTIALIAS
)
im
=
im
.
resize
((
32
,
32
),
Image
.
ANTIALIAS
)
im
=
np
.
array
(
im
).
astype
(
np
.
float32
)
im
=
np
.
array
(
im
).
astype
(
np
.
float32
)
# PIL打开图片存储顺序为H(高度),W(宽度),C(通道)。
# PaddlePaddle要求数据顺序为CHW,所以需要转换顺序。
im
=
im
.
transpose
((
2
,
0
,
1
))
# CHW
im
=
im
.
transpose
((
2
,
0
,
1
))
# CHW
# CIFAR训练图片通道顺序为B(蓝),G(绿),R(红),
# 而PIL打开图片默认通道顺序为RGB,因为需要交换通道。
im
=
im
[(
2
,
1
,
0
),:,:]
# BGR
im
=
im
[(
2
,
1
,
0
),:,:]
# BGR
im
=
im
.
flatten
()
im
=
im
.
flatten
()
im
=
im
/
255.0
im
=
im
/
255.0
...
...
03.image_classification/index.en.html
浏览文件 @
92d65ed4
...
@@ -533,7 +533,13 @@ def load_image(file):
...
@@ -533,7 +533,13 @@ def load_image(file):
im = Image.open(file)
im = Image.open(file)
im = im.resize((32, 32), Image.ANTIALIAS)
im = im.resize((32, 32), Image.ANTIALIAS)
im = np.array(im).astype(np.float32)
im = np.array(im).astype(np.float32)
# The storage order of the loaded image is W(widht),
# H(height), C(channel). PaddlePaddle requires
# the CHW order, so transpose them.
im = im.transpose((2, 0, 1)) # CHW
im = im.transpose((2, 0, 1)) # CHW
# In the training phase, the channel order of CIFAR
# image is B(Blue), G(green), R(Red). But PIL open
# image in RGB mode. It must swap the channel order.
im = im[(2, 1, 0),:,:] # BGR
im = im[(2, 1, 0),:,:] # BGR
im = im.flatten()
im = im.flatten()
im = im / 255.0
im = im / 255.0
...
...
03.image_classification/index.html
浏览文件 @
92d65ed4
...
@@ -525,7 +525,11 @@ def load_image(file):
...
@@ -525,7 +525,11 @@ def load_image(file):
im = Image.open(file)
im = Image.open(file)
im = im.resize((32, 32), Image.ANTIALIAS)
im = im.resize((32, 32), Image.ANTIALIAS)
im = np.array(im).astype(np.float32)
im = np.array(im).astype(np.float32)
# PIL打开图片存储顺序为H(高度),W(宽度),C(通道)。
# PaddlePaddle要求数据顺序为CHW,所以需要转换顺序。
im = im.transpose((2, 0, 1)) # CHW
im = im.transpose((2, 0, 1)) # CHW
# CIFAR训练图片通道顺序为B(蓝),G(绿),R(红),
# 而PIL打开图片默认通道顺序为RGB,因为需要交换通道。
im = im[(2, 1, 0),:,:] # BGR
im = im[(2, 1, 0),:,:] # BGR
im = im.flatten()
im = im.flatten()
im = im / 255.0
im = im / 255.0
...
...
03.image_classification/train.py
浏览文件 @
92d65ed4
...
@@ -98,7 +98,13 @@ def main():
...
@@ -98,7 +98,13 @@ def main():
im
=
Image
.
open
(
file
)
im
=
Image
.
open
(
file
)
im
=
im
.
resize
((
32
,
32
),
Image
.
ANTIALIAS
)
im
=
im
.
resize
((
32
,
32
),
Image
.
ANTIALIAS
)
im
=
np
.
array
(
im
).
astype
(
np
.
float32
)
im
=
np
.
array
(
im
).
astype
(
np
.
float32
)
# The storage order of the loaded image is W(widht),
# H(height), C(channel). PaddlePaddle requires
# the CHW order, so transpose them.
im
=
im
.
transpose
((
2
,
0
,
1
))
# CHW
im
=
im
.
transpose
((
2
,
0
,
1
))
# CHW
# In the training phase, the channel order of CIFAR
# image is B(Blue), G(green), R(Red). But PIL open
# image in RGB mode. It must swap the channel order.
im
=
im
[(
2
,
1
,
0
),
:,
:]
# BGR
im
=
im
[(
2
,
1
,
0
),
:,
:]
# BGR
im
=
im
.
flatten
()
im
=
im
.
flatten
()
im
=
im
/
255.0
im
=
im
/
255.0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录