mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-11-03 11:02:01 +08:00
[Doc] Add English version of serving/ and java/andriod/. (#963)
* 第一次提交 * 补充一处漏翻译 * 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
This commit is contained in:
@@ -5,17 +5,18 @@ English | [中文](../../cn/faq/develop_a_new_model.md)
|
||||
|
||||
| Step | Description | Create or modify the files |
|
||||
|:-----------:|:--------------------------------------------------------------------------------:|:-----------------------------------------:|
|
||||
| [1](#step2) | Add a model implementation to the corresponding task module in FastDeploy/vision | resnet.h、resnet.cc、vision.h |
|
||||
| [2](#step4) | Python interface binding via pybind | resnet_pybind.cc、classification_pybind.cc |
|
||||
| [3](#step5) | Use Python to call Interface | resnet.py、\_\_init\_\_.py |
|
||||
| [1](#step2) | Add a model implementation to the corresponding task module in FastDeploy/vision | resnet.h, resnet.cc, vision.h |
|
||||
| [2](#step4) | Python interface binding via pybind | resnet_pybind.cc, classification_pybind.cc |
|
||||
| [3](#step5) | Use Python to call Interface | resnet.py, \_\_init\_\_.py |
|
||||
|
||||
After completing the above 3 steps, an external model is integrated.
|
||||
|
||||
If you want to contribute your code to FastDeploy, it is very kind of you to add test code, instructions (Readme), and code annotations for the added model in the [test](#test).
|
||||
|
||||
## Model Integration
|
||||
## Model Integration <span id="modelsupport"></span>
|
||||
|
||||
### Prepare the models <span id="step1"></span>
|
||||
|
||||
### Prepare the models
|
||||
|
||||
Before integrating external models, it is important to convert the trained models (.pt, .pdparams, etc.) to the model formats (.onnx, .pdmodel) that FastDeploy supports for deployment. Most open source repositories provide model conversion scripts for developers. As torchvision does not provide conversion scripts, developers can write conversion scripts manually. In this demo, we convert `torchvison.models.resnet50` to `resnet50.onnx` with the following code for your reference.
|
||||
|
||||
@@ -40,7 +41,7 @@ torch.onnx.export(model,
|
||||
|
||||
Running the above script will generate a`resnet50.onnx` file.
|
||||
|
||||
### C++
|
||||
### C++ <span id="step2"></span>
|
||||
|
||||
* Create`resnet.h` file
|
||||
* Create a path
|
||||
@@ -64,7 +65,7 @@ class FASTDEPLOY_DECL ResNet : public FastDeployModel {
|
||||
* Create a path
|
||||
* FastDeploy/fastdeploy/vision/classification/contrib/resnet.cc (FastDeploy/C++ code/vision/task name/external model name/model name.cc)
|
||||
* Create content
|
||||
* Implement the specific logic of the functions declared in `resnet.h` to `resnet.cc`, where `PreProcess` and `PostProcess` need to refer to the official source library for pre- and post-processing logic reproduction. The specific logic of each ResNet function is as follows. For more detailed code, please refer to [resnet.cc](https:// github.com/PaddlePaddle/FastDeploy/pull/347/files#diff-d229d702de28345253a53f2a5839fd2c638f3d32fffa6a7d04d23db9da13a871).
|
||||
* Implement the specific logic of the functions declared in `resnet.h` to `resnet.cc`, where `PreProcess` and `PostProcess` need to refer to the official source library for pre- and post-processing logic reproduction. The specific logic of each ResNet function is as follows. For more detailed code, please refer to [resnet.cc](https://github.com/PaddlePaddle/FastDeploy/pull/347/files#diff-d229d702de28345253a53f2a5839fd2c638f3d32fffa6a7d04d23db9da13a871).
|
||||
|
||||
```C++
|
||||
ResNet::ResNet(...) {
|
||||
@@ -93,7 +94,7 @@ bool ResNet::Predict(cv::Mat* im, ClassifyResult* result, int topk) {
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
<span id="step3"></span>
|
||||
* Add new model file to`vision.h`
|
||||
* modify location
|
||||
* FastDeploy/fastdeploy/vision.h
|
||||
@@ -105,7 +106,7 @@ bool ResNet::Predict(cv::Mat* im, ClassifyResult* result, int topk) {
|
||||
#endif
|
||||
```
|
||||
|
||||
### Pybind
|
||||
### Pybind <span id="step4"></span>
|
||||
|
||||
* Create Pybind file
|
||||
|
||||
@@ -146,7 +147,7 @@ bool ResNet::Predict(cv::Mat* im, ClassifyResult* result, int topk) {
|
||||
}
|
||||
```
|
||||
|
||||
### Python
|
||||
### Python <span id="step5"></span>
|
||||
|
||||
* Create`resnet.py`file
|
||||
* Create path
|
||||
@@ -167,7 +168,7 @@ class ResNet(FastDeployModel):
|
||||
def size(self, wh):
|
||||
...
|
||||
```
|
||||
|
||||
<span id="step6"></span>
|
||||
* Import ResNet classes
|
||||
* modify path
|
||||
* FastDeploy/python/fastdeploy/vision/classification/\_\_init\_\_.py (FastDeploy/Python code/fastdeploy/vision model/task name/\_\_init\_\_.py)
|
||||
@@ -177,7 +178,7 @@ class ResNet(FastDeployModel):
|
||||
from .contrib.resnet import ResNet
|
||||
```
|
||||
|
||||
## Test
|
||||
## Test <span id="test"></span>
|
||||
|
||||
### Compile
|
||||
|
||||
@@ -229,7 +230,7 @@ pip install fastdeploy_gpu_python-Version number-cpxx-cpxxm-system architecture.
|
||||
```
|
||||
|
||||
* C++
|
||||
* Write CmakeLists、C++ code and README.md . Please refer to[cpp/](https://github.com/PaddlePaddle/FastDeploy/pull/347/files#diff-afcbe607b796509581f89e38b84190717f1eeda2df0419a2ac9034197ead5f96)
|
||||
* Write CmakeLists、C++ code and README.md . Please refer to [cpp/](https://github.com/PaddlePaddle/FastDeploy/pull/347/files#diff-afcbe607b796509581f89e38b84190717f1eeda2df0419a2ac9034197ead5f96)
|
||||
* Compile infer.cc
|
||||
* Path:FastDeploy/examples/vision/classification/resnet/cpp/
|
||||
|
||||
@@ -240,7 +241,7 @@ make
|
||||
```
|
||||
|
||||
* Python
|
||||
* Please refer to[python/](https://github.com/PaddlePaddle/FastDeploy/pull/347/files#diff-5a0d6be8c603a8b81454ac14c17fb93555288d9adf92bbe40454449309700135) for Python code and Readme.md
|
||||
* Please refer to [python/](https://github.com/PaddlePaddle/FastDeploy/pull/347/files#diff-5a0d6be8c603a8b81454ac14c17fb93555288d9adf92bbe40454449309700135) for Python code and Readme.md
|
||||
|
||||
### Annotate the Code
|
||||
|
||||
@@ -249,7 +250,7 @@ make
|
||||
To make the code clear for understanding, developers can annotate the newly-added code.
|
||||
|
||||
- C++ code
|
||||
Developers need to add annotations for functions and variables in the resnet.h file, there are three annotating methods as follows, please refer to [resnet.h](https://github.com/PaddlePaddle/FastDeploy/pull/347/files#diff- 69128489e918f305c208476ba793d8167e77de2aa7cadf5dcbac30da448bd28e) for more details.
|
||||
Developers need to add annotations for functions and variables in the resnet.h file, there are three annotating methods as follows, please refer to [resnet.h](https://github.com/PaddlePaddle/FastDeploy/pull/347/files#diff-69128489e918f305c208476ba793d8167e77de2aa7cadf5dcbac30da448bd28e) for more details.
|
||||
|
||||
```C++
|
||||
/** \brief Predict for the input "im", the result will be saved in "result".
|
||||
|
||||
@@ -92,7 +92,7 @@ In particular, for the configuration method of the dependency library required b
|
||||
|
||||
### 3.2 SDK usage method 2: Visual Studio 2019 creates sln project using C++ SDK
|
||||
|
||||
This section is for non-CMake users and describes how to create a sln project in Visual Studio 2019 to use FastDeploy C++ SDK. CMake users please read the next section directly. In addition, this section is a special thanks to "Awake to the Southern Sky" for his tutorial on FastDeploy: [How to deploy PaddleDetection target detection model on Windows using FastDeploy C++].(https://www.bilibili.com/read/cv18807232)
|
||||
This section is for non-CMake users and describes how to create a sln project in Visual Studio 2019 to use FastDeploy C++ SDK. CMake users please read the next section directly. In addition, this section is a special thanks to "Awake to the Southern Sky" for his tutorial on FastDeploy: [How to deploy PaddleDetection target detection model on Windows using FastDeploy C++](https://www.bilibili.com/read/cv18807232).
|
||||
|
||||
<div id="VisualStudio2019Sln"></div>
|
||||
|
||||
@@ -192,7 +192,7 @@ Compile successfully, you can see the exe saved in:
|
||||
D:\qiuyanjun\fastdeploy_test\infer_ppyoloe\x64\Release\infer_ppyoloe.exe
|
||||
```
|
||||
|
||||
(2)Execute the executable file and get the inference result. First you need to copy all the dlls to the directory where the exe is located. At the same time, you also need to download and extract the pyoloe model files and test images, and then copy them to the directory where the exe is located. Special note, the exe needs to run when the dependency library configuration method, please refer to the section: [various methods to configure the exe to run the required dependency library](#CommandLineDeps)
|
||||
(2)Execute the executable file and get the inference result. First you need to copy all the dlls to the directory where the exe is located. At the same time, you also need to download and extract the pyoloe model files and test images, and then copy them to the directory where the exe is located. Special note, the exe needs to run when the dependency library configuration method, please refer to the section: [various methods to configure the exe to run the required dependency library](#CommandLineDeps).
|
||||
|
||||

|
||||
|
||||
@@ -331,7 +331,7 @@ Open the saved image to view the visualization results at:
|
||||
<img src="https://user-images.githubusercontent.com/19339784/184326520-7075e907-10ed-4fad-93f8-52d0e35d4964.jpg", width=480px, height=320px />
|
||||
</div>
|
||||
|
||||
Special note, the exe needs to run when the dependency library configuration method, please refer to the section: [a variety of methods to configure the exe to run the required dependency library](#CommandLineDeps)
|
||||
Special note, the exe needs to run when the dependency library configuration method, please refer to the section: [a variety of methods to configure the exe to run the required dependency library](#CommandLineDeps).
|
||||
|
||||
## 4. Multiple methods to Configure the Required Dependencies for the Exe Runtime
|
||||
<div id="CommandLineDeps"></div>
|
||||
|
||||
Reference in New Issue
Block a user