mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
[Doc]Add English version of documents in examples/ (#1042)
* 第一次提交 * 补充一处漏翻译 * deleted: docs/en/quantize.md * Update one translation * Update en version * Update one translation in code * Standardize one writing * Standardize one writing * Update some en version * Fix a grammer problem * Update en version for api/vision result * Merge branch 'develop' of https://github.com/charl-u/FastDeploy into develop * Checkout the link in README in vision_results/ to the en documents * Modify a title * Add link to serving/docs/ * Finish translation of demo.md * Update english version of serving/docs/ * Update title of readme * Update some links * Modify a title * Update some links * Update en version of java android README * Modify some titles * Modify some titles * Modify some titles * modify article to document * update some english version of documents in examples * Add english version of documents in examples/visions * Sync to current branch * Add english version of documents in examples
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
English | [简体中文](README_CN.md)
|
||||
# Python推理
|
||||
|
||||
在运行demo前,需确认以下两个步骤
|
||||
Before running demo, the following two steps need to be confirmed:
|
||||
|
||||
- 1. 软硬件环境满足要求,参考[FastDeploy环境要求](../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
||||
- 2. FastDeploy Python whl包安装,参考[FastDeploy Python安装](../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
||||
- 1. Hardware and software environment meets the requirements. Please refer to [Environment requirements for FastDeploy](../../../docs/en/build_and_install/download_prebuilt_libraries.md).
|
||||
- 2. Install FastDeploy Python whl package, please refer to [FastDeploy Python Installation](../../../docs/cn/build_and_install/download_prebuilt_libraries.md).
|
||||
|
||||
本文档以 PaddleClas 分类模型 MobileNetV2 为例展示 CPU 上的推理示例
|
||||
This document shows an inference example on the CPU using the PaddleClas classification model MobileNetV2 as an example.
|
||||
|
||||
## 1. 获取模型
|
||||
## 1. Obtaining the model
|
||||
|
||||
``` python
|
||||
import fastdeploy as fd
|
||||
@@ -16,7 +17,7 @@ model_url = "https://bj.bcebos.com/fastdeploy/models/mobilenetv2.tgz"
|
||||
fd.download_and_decompress(model_url, path=".")
|
||||
```
|
||||
|
||||
## 2. 配置后端
|
||||
## 2. Backend Configuration
|
||||
|
||||
``` python
|
||||
option = fd.RuntimeOption()
|
||||
@@ -24,30 +25,30 @@ option = fd.RuntimeOption()
|
||||
option.set_model_path("mobilenetv2/inference.pdmodel",
|
||||
"mobilenetv2/inference.pdiparams")
|
||||
|
||||
# **** CPU 配置 ****
|
||||
# **** CPU Configuration ****
|
||||
option.use_cpu()
|
||||
option.use_ort_backend()
|
||||
option.set_cpu_thread_num(12)
|
||||
|
||||
# 初始化构造runtime
|
||||
# Initialise runtime
|
||||
runtime = fd.Runtime(option)
|
||||
|
||||
# 获取模型输入名
|
||||
# Get model input name
|
||||
input_name = runtime.get_input_info(0).name
|
||||
|
||||
# 构造随机数据进行推理
|
||||
# Constructing random data for inference
|
||||
results = runtime.infer({
|
||||
input_name: np.random.rand(1, 3, 224, 224).astype("float32")
|
||||
})
|
||||
|
||||
print(results[0].shape)
|
||||
```
|
||||
加载完成,会输出提示如下,说明初始化的后端,以及运行的硬件设备
|
||||
When loading is complete, you will get the following output information indicating the initialized backend and the hardware devices.
|
||||
```
|
||||
[INFO] fastdeploy/fastdeploy_runtime.cc(283)::Init Runtime initialized with Backend::OrtBackend in device Device::CPU.
|
||||
```
|
||||
|
||||
## 其它文档
|
||||
## Other Documents
|
||||
|
||||
- [Runtime C++ 示例](../cpp)
|
||||
- [切换模型推理的硬件和后端](../../../docs/cn/faq/how_to_change_backend.md)
|
||||
- [A C++ example for Runtime C++](../cpp)
|
||||
- [Switching hardware and backend for model inference](../../../docs/en/faq/how_to_change_backend.md)
|
||||
|
54
examples/runtime/python/README_CN.md
Normal file
54
examples/runtime/python/README_CN.md
Normal file
@@ -0,0 +1,54 @@
|
||||
简体中文 | [English](README.md)
|
||||
# Python推理
|
||||
|
||||
在运行demo前,需确认以下两个步骤
|
||||
|
||||
- 1. 软硬件环境满足要求,参考[FastDeploy环境要求](../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
||||
- 2. FastDeploy Python whl包安装,参考[FastDeploy Python安装](../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
||||
|
||||
本文档以 PaddleClas 分类模型 MobileNetV2 为例展示 CPU 上的推理示例
|
||||
|
||||
## 1. 获取模型
|
||||
|
||||
``` python
|
||||
import fastdeploy as fd
|
||||
|
||||
model_url = "https://bj.bcebos.com/fastdeploy/models/mobilenetv2.tgz"
|
||||
fd.download_and_decompress(model_url, path=".")
|
||||
```
|
||||
|
||||
## 2. 配置后端
|
||||
|
||||
``` python
|
||||
option = fd.RuntimeOption()
|
||||
|
||||
option.set_model_path("mobilenetv2/inference.pdmodel",
|
||||
"mobilenetv2/inference.pdiparams")
|
||||
|
||||
# **** CPU 配置 ****
|
||||
option.use_cpu()
|
||||
option.use_ort_backend()
|
||||
option.set_cpu_thread_num(12)
|
||||
|
||||
# 初始化构造runtime
|
||||
runtime = fd.Runtime(option)
|
||||
|
||||
# 获取模型输入名
|
||||
input_name = runtime.get_input_info(0).name
|
||||
|
||||
# 构造随机数据进行推理
|
||||
results = runtime.infer({
|
||||
input_name: np.random.rand(1, 3, 224, 224).astype("float32")
|
||||
})
|
||||
|
||||
print(results[0].shape)
|
||||
```
|
||||
加载完成,会输出提示如下,说明初始化的后端,以及运行的硬件设备
|
||||
```
|
||||
[INFO] fastdeploy/fastdeploy_runtime.cc(283)::Init Runtime initialized with Backend::OrtBackend in device Device::CPU.
|
||||
```
|
||||
|
||||
## 其它文档
|
||||
|
||||
- [Runtime C++ 示例](../cpp)
|
||||
- [切换模型推理的硬件和后端](../../../docs/cn/faq/how_to_change_backend.md)
|
Reference in New Issue
Block a user