Upload test_infer_sdxl_unet_trt_onnx.py
Browse files
test_infer_sdxl_unet_trt_onnx.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from sdxl_unet2_trt import MyStableDiffusionXLPipeline
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
"""
|
| 6 |
+
With the current pipeline it just use to compare the Unet Diffusers vs Unet Onnx (calibrate)
|
| 7 |
+
Cannot get the result image
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
pipe = MyStableDiffusionXLPipeline.from_pretrained(
|
| 11 |
+
"stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float32
|
| 12 |
+
)
|
| 13 |
+
# pipe = pipe.to("cuda")
|
| 14 |
+
|
| 15 |
+
"""
|
| 16 |
+
For compare the Unet Diffusers vs Unet Onnx (calibrate)
|
| 17 |
+
"""
|
| 18 |
+
prompt = 'Portrait shot of a woman, yellow shirt, photograph'
|
| 19 |
+
image = pipe(prompt)
|
| 20 |
+
|
| 21 |
+
"""
|
| 22 |
+
Uncommand for get the result image
|
| 23 |
+
"""
|
| 24 |
+
# prompt = 'Portrait shot of a woman, yellow shirt, photograph'
|
| 25 |
+
# image = pipe(prompt).images[0]
|
| 26 |
+
|
| 27 |
+
# Save the image
|
| 28 |
+
# save_path = "/home/tiennv/trang/model_unet_quantize_full_onnx_2/image_sdxl_trt_b4.png"
|
| 29 |
+
# image.save(save_path)
|