owenzhangzhengzhong commited on
Commit
8085a45
·
verified ·
1 Parent(s): abaab6c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -0
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-to-image
3
+ ---
4
+ # Model Card for stable-diffusion-1.5_iofp32_amdgpu
5
+
6
+ Model was converted from https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5 with additional AMD Optimizations
7
+
8
+
9
+ ## How to Get Started with the Model
10
+
11
+ Use the code below to get started with the model.
12
+
13
+ With Python using Diffusers OnnxStableDiffusionPipeline
14
+
15
+ Required Modules
16
+ ```
17
+ accelerate
18
+ numpy==1.26.4 # Due to newer version of numpy changing dtype when multiplying
19
+ diffusers
20
+ torch
21
+ transformers
22
+ onnxruntime-directml
23
+ ```
24
+
25
+ Python Script
26
+ ```
27
+ import onnxruntime as ort
28
+ from diffusers import OnnxStableDiffusionPipeline
29
+
30
+ model_dir = "D:\\Models\\stable-diffusion-v1-5_io32"
31
+
32
+ batch_size = 1
33
+ num_inference_steps = 30
34
+ image_size = 512
35
+ guidance_scale = 7.5
36
+ prompt = "a beautiful cabin in the mountains of Lake Tahoe"
37
+
38
+ ort.set_default_logger_severity(3)
39
+
40
+ sess_options = ort.SessionOptions()
41
+ sess_options.enable_mem_pattern = False
42
+
43
+ sess_options.add_free_dimension_override_by_name("unet_sample_batch", batch_size * 2)
44
+ sess_options.add_free_dimension_override_by_name("unet_sample_channels", 4)
45
+ sess_options.add_free_dimension_override_by_name("unet_sample_height", image_size // 8)
46
+ sess_options.add_free_dimension_override_by_name("unet_sample_width", image_size // 8)
47
+ sess_options.add_free_dimension_override_by_name("unet_time_batch", batch_size)
48
+ sess_options.add_free_dimension_override_by_name("unet_hidden_batch", batch_size * 2)
49
+ sess_options.add_free_dimension_override_by_name("unet_hidden_sequence", 77)
50
+
51
+ pipeline = OnnxStableDiffusionPipeline.from_pretrained(
52
+ model_dir, provider="DmlExecutionProvider", sess_options=sess_options
53
+ )
54
+
55
+ result = pipeline(
56
+ [prompt] * batch_size,
57
+ num_inference_steps=num_inference_steps,
58
+ callback=None,
59
+ height=image_size,
60
+ width=image_size,
61
+ guidance_scale=guidance_scale,
62
+ generator=None
63
+ )
64
+
65
+ output_path = "output.png"
66
+ result.images[0].save(output_path)
67
+
68
+ print(f"Generated {output_path}")
69
+ ```
70
+
71
+ ### Inference Results
72
+
73
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/65f275d7b06ca1ff48a356fb/g93w4ATPtUZndc0Dt9Smp.png)
74
+
75
+