Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
56284eda
B
book
项目概览
PaddlePaddle
/
book
通知
16
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看板
提交
56284eda
编写于
4月 21, 2017
作者:
L
liaogang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add python current path for inference
上级
637befd9
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
34 addition
and
10 deletion
+34
-10
02.recognize_digits/README.en.md
02.recognize_digits/README.en.md
+4
-1
02.recognize_digits/README.md
02.recognize_digits/README.md
+4
-1
02.recognize_digits/index.en.html
02.recognize_digits/index.en.html
+4
-1
02.recognize_digits/index.html
02.recognize_digits/index.html
+4
-1
02.recognize_digits/train.py
02.recognize_digits/train.py
+3
-1
03.image_classification/README.en.md
03.image_classification/README.en.md
+3
-1
03.image_classification/README.md
03.image_classification/README.md
+3
-1
03.image_classification/index.en.html
03.image_classification/index.en.html
+3
-1
03.image_classification/index.html
03.image_classification/index.html
+3
-1
03.image_classification/train.py
03.image_classification/train.py
+3
-1
未找到文件。
02.recognize_digits/README.en.md
浏览文件 @
56284eda
...
...
@@ -321,14 +321,17 @@ After training is done, user can use the trained model to classify images. The f
```
python
from
PIL
import
Image
import
numpy
as
np
import
os
def
load_image
(
file
):
im
=
Image
.
open
(
file
).
convert
(
'L'
)
im
=
im
.
resize
((
28
,
28
),
Image
.
ANTIALIAS
)
im
=
np
.
array
(
im
).
astype
(
np
.
float32
).
flatten
()
im
=
im
/
255.0
return
im
test_data
=
[]
test_data
.
append
((
load_image
(
'image/infer_3.png'
),))
cur_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
test_data
.
append
((
load_image
(
cur_dir
+
'/image/infer_3.png'
),))
probs
=
paddle
.
infer
(
output_layer
=
predict
,
parameters
=
parameters
,
input
=
test_data
)
...
...
02.recognize_digits/README.md
浏览文件 @
56284eda
...
...
@@ -317,14 +317,17 @@ trainer.train(
```
python
from
PIL
import
Image
import
numpy
as
np
import
os
def
load_image
(
file
):
im
=
Image
.
open
(
file
).
convert
(
'L'
)
im
=
im
.
resize
((
28
,
28
),
Image
.
ANTIALIAS
)
im
=
np
.
array
(
im
).
astype
(
np
.
float32
).
flatten
()
im
=
im
/
255.0
return
im
test_data
=
[]
test_data
.
append
((
load_image
(
'image/infer_3.png'
),))
cur_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
test_data
.
append
((
load_image
(
cur_dir
+
'/image/infer_3.png'
),))
probs
=
paddle
.
infer
(
output_layer
=
predict
,
parameters
=
parameters
,
input
=
test_data
)
...
...
02.recognize_digits/index.en.html
浏览文件 @
56284eda
...
...
@@ -363,14 +363,17 @@ After training is done, user can use the trained model to classify images. The f
```python
from PIL import Image
import numpy as np
import os
def load_image(file):
im = Image.open(file).convert('L')
im = im.resize((28, 28), Image.ANTIALIAS)
im = np.array(im).astype(np.float32).flatten()
im = im / 255.0
return im
test_data = []
test_data.append((load_image('image/infer_3.png'),))
cur_dir = os.path.dirname(os.path.realpath(__file__))
test_data.append((load_image(cur_dir + '/image/infer_3.png'),))
probs = paddle.infer(
output_layer=predict, parameters=parameters, input=test_data)
...
...
02.recognize_digits/index.html
浏览文件 @
56284eda
...
...
@@ -359,14 +359,17 @@ trainer.train(
```python
from PIL import Image
import numpy as np
import os
def load_image(file):
im = Image.open(file).convert('L')
im = im.resize((28, 28), Image.ANTIALIAS)
im = np.array(im).astype(np.float32).flatten()
im = im / 255.0
return im
test_data = []
test_data.append((load_image('image/infer_3.png'),))
cur_dir = os.path.dirname(os.path.realpath(__file__))
test_data.append((load_image(cur_dir + '/image/infer_3.png'),))
probs = paddle.infer(
output_layer=predict, parameters=parameters, input=test_data)
...
...
02.recognize_digits/train.py
浏览文件 @
56284eda
import
gzip
import
os
from
PIL
import
Image
import
numpy
as
np
import
paddle.v2
as
paddle
...
...
@@ -114,7 +115,8 @@ def main():
return
im
test_data
=
[]
test_data
.
append
((
load_image
(
'image/infer_3.png'
),
))
cur_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
test_data
.
append
((
load_image
(
cur_dir
+
'/image/infer_3.png'
),
))
probs
=
paddle
.
infer
(
output_layer
=
predict
,
parameters
=
parameters
,
input
=
test_data
)
...
...
03.image_classification/README.en.md
浏览文件 @
56284eda
...
...
@@ -488,6 +488,7 @@ After training is done, users can use the trained model to classify images. The
```
python
from
PIL
import
Image
import
numpy
as
np
import
os
def
load_image
(
file
):
im
=
Image
.
open
(
file
)
im
=
im
.
resize
((
32
,
32
),
Image
.
ANTIALIAS
)
...
...
@@ -495,7 +496,8 @@ def load_image(file):
im
=
im
/
255.0
return
im
test_data
=
[]
test_data
.
append
((
load_image
(
'image/dog.png'
),))
cur_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
test_data
.
append
((
load_image
(
cur_dir
+
'/image/dog.png'
),)
probs
=
paddle
.
infer
(
output_layer
=
out
,
parameters
=
parameters
,
input
=
test_data
)
...
...
03.image_classification/README.md
浏览文件 @
56284eda
...
...
@@ -480,6 +480,7 @@ Test with Pass 0, {'classification_error_evaluator': 0.885200023651123}
```
python
from
PIL
import
Image
import
numpy
as
np
import
os
def
load_image
(
file
):
im
=
Image
.
open
(
file
)
im
=
im
.
resize
((
32
,
32
),
Image
.
ANTIALIAS
)
...
...
@@ -487,7 +488,8 @@ def load_image(file):
im
=
im
/
255.0
return
im
test_data
=
[]
test_data
.
append
((
load_image
(
'image/dog.png'
),))
cur_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
test_data
.
append
((
load_image
(
cur_dir
+
'/image/dog.png'
),)
probs
=
paddle
.
infer
(
output_layer
=
out
,
parameters
=
parameters
,
input
=
test_data
)
...
...
03.image_classification/index.en.html
浏览文件 @
56284eda
...
...
@@ -530,6 +530,7 @@ After training is done, users can use the trained model to classify images. The
```python
from PIL import Image
import numpy as np
import os
def load_image(file):
im = Image.open(file)
im = im.resize((32, 32), Image.ANTIALIAS)
...
...
@@ -537,7 +538,8 @@ def load_image(file):
im = im / 255.0
return im
test_data = []
test_data.append((load_image('image/dog.png'),))
cur_dir = os.path.dirname(os.path.realpath(__file__))
test_data.append((load_image(cur_dir + '/image/dog.png'),)
probs = paddle.infer(
output_layer=out, parameters=parameters, input=test_data)
...
...
03.image_classification/index.html
浏览文件 @
56284eda
...
...
@@ -522,6 +522,7 @@ Test with Pass 0, {'classification_error_evaluator': 0.885200023651123}
```python
from PIL import Image
import numpy as np
import os
def load_image(file):
im = Image.open(file)
im = im.resize((32, 32), Image.ANTIALIAS)
...
...
@@ -529,7 +530,8 @@ def load_image(file):
im = im / 255.0
return im
test_data = []
test_data.append((load_image('image/dog.png'),))
cur_dir = os.path.dirname(os.path.realpath(__file__))
test_data.append((load_image(cur_dir + '/image/dog.png'),)
probs = paddle.infer(
output_layer=out, parameters=parameters, input=test_data)
...
...
03.image_classification/train.py
浏览文件 @
56284eda
...
...
@@ -94,6 +94,7 @@ def main():
# inference
from
PIL
import
Image
import
numpy
as
np
import
os
def
load_image
(
file
):
im
=
Image
.
open
(
file
)
...
...
@@ -103,7 +104,8 @@ def main():
return
im
test_data
=
[]
test_data
.
append
((
load_image
(
'image/dog.png'
),
))
cur_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
test_data
.
append
((
load_image
(
cur_dir
+
'/image/dog.png'
),
))
probs
=
paddle
.
infer
(
output_layer
=
out
,
parameters
=
parameters
,
input
=
test_data
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录