未验证 提交 176734ad 编写于 作者: D dzhwinter 提交者: GitHub

Merge pull request #582 from JiabinYang/book03_refine

Refine comments and the presentation of inference result for book"03.image_classification"
...@@ -160,6 +160,7 @@ import paddle ...@@ -160,6 +160,7 @@ import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import numpy import numpy
import sys import sys
from __future__ import print_function
``` ```
本教程中我们提供了VGG和ResNet两个模型的配置。 本教程中我们提供了VGG和ResNet两个模型的配置。
...@@ -426,7 +427,7 @@ def event_handler(event): ...@@ -426,7 +427,7 @@ def event_handler(event):
通过`trainer.train`函数训练: 通过`trainer.train`函数训练:
**注意:** CPU,每个 Epoch 将花费大约15~20分钟。这部分可能需要一段时间。请随意修改代码,在GPU上运行测试,以提高培训速度。 **注意:** CPU,每个 Epoch 将花费大约15~20分钟。这部分可能需要一段时间。请随意修改代码,在GPU上运行测试,以提高训练速度。
```python ```python
trainer.train( trainer.train(
...@@ -499,10 +500,10 @@ img = load_image(cur_dir + '/image/dog.png') ...@@ -499,10 +500,10 @@ img = load_image(cur_dir + '/image/dog.png')
```python ```python
inferencer = fluid.Inferencer( inferencer = fluid.Inferencer(
infer_func=inference_program, param_path=params_dirname, place=place) infer_func=inference_program, param_path=params_dirname, place=place)
label_list = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
# inference # inference
results = inferencer.infer({'pixel': img}) results = inferencer.infer({'pixel': img})
print("infer results: ", results) print("infer results: %s" % label_list[np.argmax(results[0])])
``` ```
## 总结 ## 总结
......
...@@ -171,6 +171,7 @@ import paddle ...@@ -171,6 +171,7 @@ import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import numpy import numpy
import sys import sys
from __future__ import print_function
``` ```
Now we are going to walk you through the implementations of the VGG and ResNet. Now we are going to walk you through the implementations of the VGG and ResNet.
...@@ -514,9 +515,10 @@ Now we are ready to do inference. ...@@ -514,9 +515,10 @@ Now we are ready to do inference.
inferencer = fluid.Inferencer( inferencer = fluid.Inferencer(
infer_func=inference_program, param_path=params_dirname, place=place) infer_func=inference_program, param_path=params_dirname, place=place)
label_list = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
# inference # inference
results = inferencer.infer({'pixel': img}) results = inferencer.infer({'pixel': img})
print("infer results: ", results) print("infer results: %s" % label_list[np.argmax(results[0])])
``` ```
......
...@@ -202,6 +202,7 @@ import paddle ...@@ -202,6 +202,7 @@ import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import numpy import numpy
import sys import sys
from __future__ import print_function
``` ```
本教程中我们提供了VGG和ResNet两个模型的配置。 本教程中我们提供了VGG和ResNet两个模型的配置。
...@@ -468,7 +469,7 @@ def event_handler(event): ...@@ -468,7 +469,7 @@ def event_handler(event):
通过`trainer.train`函数训练: 通过`trainer.train`函数训练:
**注意:** CPU,每个 Epoch 将花费大约15~20分钟。这部分可能需要一段时间。请随意修改代码,在GPU上运行测试,以提高培训速度。 **注意:** CPU,每个 Epoch 将花费大约15~20分钟。这部分可能需要一段时间。请随意修改代码,在GPU上运行测试,以提高训练速度。
```python ```python
trainer.train( trainer.train(
...@@ -541,10 +542,10 @@ img = load_image(cur_dir + '/image/dog.png') ...@@ -541,10 +542,10 @@ img = load_image(cur_dir + '/image/dog.png')
```python ```python
inferencer = fluid.Inferencer( inferencer = fluid.Inferencer(
infer_func=inference_program, param_path=params_dirname, place=place) infer_func=inference_program, param_path=params_dirname, place=place)
label_list = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
# inference # inference
results = inferencer.infer({'pixel': img}) results = inferencer.infer({'pixel': img})
print("infer results: ", results) print("infer results: %s" % label_list[np.argmax(results[0])])
``` ```
## 总结 ## 总结
......
...@@ -213,6 +213,7 @@ import paddle ...@@ -213,6 +213,7 @@ import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import numpy import numpy
import sys import sys
from __future__ import print_function
``` ```
Now we are going to walk you through the implementations of the VGG and ResNet. Now we are going to walk you through the implementations of the VGG and ResNet.
...@@ -556,9 +557,10 @@ Now we are ready to do inference. ...@@ -556,9 +557,10 @@ Now we are ready to do inference.
inferencer = fluid.Inferencer( inferencer = fluid.Inferencer(
infer_func=inference_program, param_path=params_dirname, place=place) infer_func=inference_program, param_path=params_dirname, place=place)
label_list = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
# inference # inference
results = inferencer.infer({'pixel': img}) results = inferencer.infer({'pixel': img})
print("infer results: ", results) print("infer results: %s" % label_list[np.argmax(results[0])])
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册