happyme531 commited on
Commit
f2db482
·
verified ·
1 Parent(s): cd2a1fe

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -30
README.md CHANGED
@@ -12,30 +12,38 @@ tags:
12
 
13
  使用RKNPU2运行Stable Diffusion 1.5 LCM 图像生成模型!!
14
 
15
- - 推理速度(RK3588): 单NPU核, 384x384分辨率, 4次迭代, 生成1张图片平均耗时约13.8秒
16
- - 内存占用: 5.2GB
 
17
 
 
 
 
18
 
19
  ## 使用方法
20
 
21
- ### 1. 克隆或者下载此仓库到本地
22
 
23
  ### 2. 安装依赖
24
 
25
  ```bash
26
- pip install diffusers pillow numpy<2
27
  ```
28
 
29
- 当然你还要安装rknn-toolkit2-lite2。
30
-
31
  ### 3. 运行
32
 
33
  ```bash
34
- python ./run_rknn-lcm.py -i ./model -o ./images --num-inference-steps 4 -s 384x384 --prompt "Majestic mountain landscape with snow-capped peaks, autumn foliage in vibrant reds and oranges, a turquoise river winding through a valley, crisp and serene atmosphere, ultra-realistic style."
35
  ```
36
 
37
  ## 模型转换
38
 
 
 
 
 
 
 
39
  ### 1. 下载模型
40
 
41
  下载一个onnx格式的Stable Diffusion 1.5 LCM模型,并放到`./model`目录下。
@@ -58,15 +66,7 @@ python ./convert-onnx-to-rknn.py -m ./model -r 384x384
58
 
59
  ## 已知问题
60
 
61
- 1. 截至目前,使用最新版本的rknn-toolkit2 2.2.0版本转换的模型仍然存在极其严重的精度损失!即使使用的是fp16数据类型。如图,上方是使用onnx模型推理的结果,下方是使用rknn模型推理的结果。所有参数均一致。并且分辨率越高,精度损失越严重。这是rknn-toolkit2的bug
62
-
63
- - 384x384:
64
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6319d0860d7478ae0069cd92/yDmipD6zHHVyMVWqero-l.png)
65
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6319d0860d7478ae0069cd92/Ieq2m-4XnAThDnTgHWjvI.png)
66
-
67
- - 256x256:
68
- ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6319d0860d7478ae0069cd92/qoagtwDKij1WGkJwqa8bz.jpeg)
69
-
70
 
71
  2. 其实模型转换脚本可以选择多个分辨率(例如"384x384,256x256"), 但这会导致模型转换失败。这是rknn-toolkit2的bug。
72
 
@@ -82,8 +82,12 @@ python ./convert-onnx-to-rknn.py -m ./model -r 384x384
82
 
83
  Run the Stable Diffusion 1.5 LCM image generation model using RKNPU2!
84
 
85
- - Inference speed (RK3588): Single NPU core, 384x384 resolution, 4 iterations, average time to generate 1 image is about 13.8 seconds
86
- - Memory usage: About 5.2GB
 
 
 
 
87
 
88
  ## Usage
89
 
@@ -92,19 +96,23 @@ Run the Stable Diffusion 1.5 LCM image generation model using RKNPU2!
92
  ### 2. Install dependencies
93
 
94
  ```bash
95
- pip install diffusers pillow numpy<2
96
  ```
97
 
98
- Of course, you also need to install rknn-toolkit2-lite2.
99
-
100
  ### 3. Run
101
 
102
  ```bash
103
- python ./run_rknn-lcm.py -i ./model -o ./images --num-inference-steps 4 -s 384x384 --prompt "Majestic mountain landscape with snow-capped peaks, autumn foliage in vibrant reds and oranges, a turquoise river winding through a valley, crisp and serene atmosphere, ultra-realistic style."
104
  ```
105
 
106
  ## Model Conversion
107
 
 
 
 
 
 
 
108
  ### 1. Download the model
109
 
110
  Download a Stable Diffusion 1.5 LCM model in ONNX format and place it in the `./model` directory.
@@ -127,14 +135,7 @@ Note that the higher the resolution, the larger the model and the longer the con
127
 
128
  ## Known Issues
129
 
130
- 1. As of now, models converted using the latest version of rknn-toolkit2 (version 2.2.0) still suffer from severe precision loss, even when using fp16 data type. As shown in the image, the top is the result of inference using the ONNX model, and the bottom is the result using the RKNN model. All parameters are the same. Moreover, the higher the resolution, the more severe the precision loss. This is a bug in rknn-toolkit2.
131
- - 384x384:
132
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6319d0860d7478ae0069cd92/yDmipD6zHHVyMVWqero-l.png)
133
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6319d0860d7478ae0069cd92/Ieq2m-4XnAThDnTgHWjvI.png)
134
-
135
- - 256x256:
136
- ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6319d0860d7478ae0069cd92/qoagtwDKij1WGkJwqa8bz.jpeg)
137
-
138
 
139
  2. Actually, the model conversion script can select multiple resolutions (e.g., "384x384,256x256"), but this causes the model conversion to fail. This is a bug in rknn-toolkit2.
140
 
 
12
 
13
  使用RKNPU2运行Stable Diffusion 1.5 LCM 图像生成模型!!
14
 
15
+ - 推理速度(RK3588, 单NPU核):
16
+ - 384x384: 文本编码器 0.05s + U-Net 2.36s/it + VAE Decoder 5.48s
17
+ - 512x512: 文本编码器 0.05s + U-Net 5.65s/it + VAE Decoder 11.13s
18
 
19
+ - 内存占用:
20
+ - 384x384: 约5.2GB
21
+ - 512x512: 约5.6GB
22
 
23
  ## 使用方法
24
 
25
+ ### 1. 克隆或者下载此仓库到本地.
26
 
27
  ### 2. 安装依赖
28
 
29
  ```bash
30
+ pip install diffusers pillow numpy<2 rknn-toolkit-lite2
31
  ```
32
 
 
 
33
  ### 3. 运行
34
 
35
  ```bash
36
+ python ./run_rknn-lcm.py -i ./model -o ./images --num-inference-steps 4 -s 512x512 --prompt "Majestic mountain landscape with snow-capped peaks, autumn foliage in vibrant reds and oranges, a turquoise river winding through a valley, crisp and serene atmosphere, ultra-realistic style."
37
  ```
38
 
39
  ## 模型转换
40
 
41
+ ### 安装依赖
42
+
43
+ ```bash
44
+ pip install diffusers pillow numpy<2 rknn-toolkit2
45
+ ```
46
+
47
  ### 1. 下载模型
48
 
49
  下载一个onnx格式的Stable Diffusion 1.5 LCM模型,并放到`./model`目录下。
 
66
 
67
  ## 已知问题
68
 
69
+ 1. ~~截至目前,使用最新版本的rknn-toolkit2 2.2.0版本转换的模型仍然存在极其严重的精度损失!即使使用的是fp16数据类型。如图,上方是使用onnx模型推理的结果,下方是使用rknn模型推理的结果。所有参数均一致。并且分辨率越高,精度损失越严重。这是rknn-toolkit2的bug。~~ (v2.3.0已修复)
 
 
 
 
 
 
 
 
70
 
71
  2. 其实模型转换脚本可以选择多个分辨率(例如"384x384,256x256"), 但这会导致模型转换失败。这是rknn-toolkit2的bug。
72
 
 
82
 
83
  Run the Stable Diffusion 1.5 LCM image generation model using RKNPU2!
84
 
85
+ - Inference speed (RK3588, single NPU core):
86
+ - 384x384: Text encoder 0.05s + U-Net 2.36s/it + VAE Decoder 5.48s
87
+ - 512x512: Text encoder 0.05s + U-Net 5.65s/it + VAE Decoder 11.13s
88
+ - Memory usage:
89
+ - 384x384: About 5.2GB
90
+ - 512x512: About 5.6GB
91
 
92
  ## Usage
93
 
 
96
  ### 2. Install dependencies
97
 
98
  ```bash
99
+ pip install diffusers pillow numpy<2 rknn-toolkit-lite2
100
  ```
101
 
 
 
102
  ### 3. Run
103
 
104
  ```bash
105
+ python ./run_rknn-lcm.py -i ./model -o ./images --num-inference-steps 4 -s 512x512 --prompt "Majestic mountain landscape with snow-capped peaks, autumn foliage in vibrant reds and oranges, a turquoise river winding through a valley, crisp and serene atmosphere, ultra-realistic style."
106
  ```
107
 
108
  ## Model Conversion
109
 
110
+ ### Install dependencies
111
+
112
+ ```bash
113
+ pip install diffusers pillow numpy<2 rknn-toolkit2
114
+ ```
115
+
116
  ### 1. Download the model
117
 
118
  Download a Stable Diffusion 1.5 LCM model in ONNX format and place it in the `./model` directory.
 
135
 
136
  ## Known Issues
137
 
138
+ 1. ~~As of now, models converted using the latest version of rknn-toolkit2 (version 2.2.0) still suffer from severe precision loss, even when using fp16 data type. As shown in the image, the top is the result of inference using the ONNX model, and the bottom is the result using the RKNN model. All parameters are the same. Moreover, the higher the resolution, the more severe the precision loss. This is a bug in rknn-toolkit2.~~ (Fixed in v2.3.0)
 
 
 
 
 
 
 
139
 
140
  2. Actually, the model conversion script can select multiple resolutions (e.g., "384x384,256x256"), but this causes the model conversion to fail. This is a bug in rknn-toolkit2.
141