mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 00:57:33 +08:00

* Create README_CN.md * Update README.md * Update README_CN.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Update README.md * Update README_CN.md * Create README_CN.md * Update README.md * Update README.md * Update and rename README_en.md to README_CN.md * Update WebDemo.md * Update and rename WebDemo_en.md to WebDemo_CN.md * Update and rename DEVELOPMENT_cn.md to DEVELOPMENT_CN.md * Update DEVELOPMENT_CN.md * Update DEVELOPMENT.md * Update RNN.md * Update and rename RNN_EN.md to RNN_CN.md * Update README.md * Update and rename README_en.md to README_CN.md * Update README.md * Update and rename README_en.md to README_CN.md * Update README.md * Update README_cn.md * Rename README_cn.md to README_CN.md * Update README.md * Update README_cn.md * Rename README_cn.md to README_CN.md * Update export.md * Update and rename export_EN.md to export_CN.md * Update README.md * Update README.md * Create README_CN.md * Update README.md * Update README.md * Update kunlunxin.md * Update classification_result.md * Update classification_result_EN.md * Rename classification_result_EN.md to classification_result_CN.md * Update detection_result.md * Update and rename detection_result_EN.md to detection_result_CN.md * Update face_alignment_result.md * Update and rename face_alignment_result_EN.md to face_alignment_result_CN.md * Update face_detection_result.md * Update and rename face_detection_result_EN.md to face_detection_result_CN.md * Update face_recognition_result.md * Update and rename face_recognition_result_EN.md to face_recognition_result_CN.md * Update headpose_result.md * Update and rename headpose_result_EN.md to headpose_result_CN.md * Update keypointdetection_result.md * Update and rename keypointdetection_result_EN.md to keypointdetection_result_CN.md * Update matting_result.md * Update and rename matting_result_EN.md to matting_result_CN.md * Update mot_result.md * Update and rename mot_result_EN.md to mot_result_CN.md * Update ocr_result.md * Update and rename ocr_result_EN.md to ocr_result_CN.md * Update segmentation_result.md * Update and rename segmentation_result_EN.md to segmentation_result_CN.md * Update README.md * Update README.md * Update quantize.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md
65 lines
3.7 KiB
Markdown
Executable File
65 lines
3.7 KiB
Markdown
Executable File
English | [简体中文](README_CN.md)
|
|
# FastDeploy Diffusion Model High-Performance Deployment
|
|
|
|
This document completes the high-performance deployment of the Diffusion model with ⚡️`FastDeploy`, based on `DiffusionPipeline` in project [Diffusers](https://github.com/huggingface/diffusers) designed by Huggingface.
|
|
|
|
### Preperation for Deployment
|
|
|
|
This example needs the deployment model after exporting the training model. Here are two ways to obtain the deployment model:
|
|
|
|
- Methods for model export. Please refer to [Model Export](export.md) to export deployment model.
|
|
- Download the deployment model. To facilitate developers to test the example, we have pre-exported some of the `Diffusion` models, so you can just download models and test them quickly:
|
|
|
|
| Model | Scheduler |
|
|
|----------|--------------|
|
|
| [CompVis/stable-diffusion-v1-4](https://bj.bcebos.com/fastdeploy/models/stable-diffusion/CompVis/stable-diffusion-v1-4.tgz) | PNDM |
|
|
| [runwayml/stable-diffusion-v1-5](https://bj.bcebos.com/fastdeploy/models/stable-diffusion/runwayml/stable-diffusion-v1-5.tgz) | EulerAncestral |
|
|
|
|
## Environment Dependency
|
|
|
|
In the example, the word splitter in CLIP model of PaddleNLP is required, so you need to run the following line to install the dependency.
|
|
|
|
```shell
|
|
pip install paddlenlp paddlepaddle-gpu
|
|
```
|
|
|
|
### Quick Experience
|
|
|
|
We are ready to start testing after model deployment. Here we will specify the model directory as well as the inference engine backend, and run the `infer.py` script to complete the inference.
|
|
|
|
```
|
|
python infer.py --model_dir stable-diffusion-v1-4/ --scheduler "pndm" --backend paddle
|
|
```
|
|
|
|
The image file is fd_astronaut_rides_horse.png. An example of the generated image is as follows (the generated image is different each time, the example is for reference only):
|
|
|
|

|
|
|
|
If the stable-diffusion-v1-5 model is used, you can run these to complete the inference.
|
|
|
|
```
|
|
# Inference on GPU
|
|
python infer.py --model_dir stable-diffusion-v1-5/ --scheduler "euler_ancestral" --backend paddle
|
|
|
|
# Inference on KunlunXin XPU
|
|
python infer.py --model_dir stable-diffusion-v1-5/ --scheduler "euler_ancestral" --backend paddle-kunlunxin
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
`infer.py` supports more command line parameters than the above example. The following is a description of each command line parameter.
|
|
|
|
| Parameter |Description |
|
|
|----------|--------------|
|
|
| --model_dir | Directory of the exported model. |
|
|
| --model_format | Model format. Default is `'paddle'`, optional list: `['paddle', 'onnx']`. |
|
|
| --backend | Inference engine backend. Default is`paddle`, optional list: `['onnx_runtime', 'paddle', 'paddle-kunlunxin']`, when the model format is `onnx`, optional list is`['onnx_runtime']`. |
|
|
| --scheduler | Scheduler in StableDiffusion model. Default is`'pndm'`, optional list `['pndm', 'euler_ancestral']`. The scheduler corresponding to the StableDiffusio model can be found in [ppdiffuser model list](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/ppdiffusers/examples/textual_inversion).|
|
|
| --unet_model_prefix | UNet model prefix, default is `unet`. |
|
|
| --vae_model_prefix | VAE model prefix, defalut is `vae_decoder`. |
|
|
| --text_encoder_model_prefix | TextEncoder model prefix, default is `text_encoder`. |
|
|
| --inference_steps | Running times of UNet model, default is 100. |
|
|
| --image_path | Path to the generated images, defalut is `fd_astronaut_rides_horse.png`. |
|
|
| --device_id | gpu id. If `device_id` is -1, cpu is used for inference. |
|
|
| --use_fp16 | Indicates if fp16 is used, default is `False`. Can be set to `True` when using tensorrt or paddle-tensorrt backend. |
|