Alrightlone commited on
Commit
8e3049f
·
verified ·
1 Parent(s): 65ea008

Initial release

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ sdxl1.png filter=lfs diff=lfs merge=lfs -text
37
+ sdxl2.png filter=lfs diff=lfs merge=lfs -text
38
+ sdxl3.png filter=lfs diff=lfs merge=lfs -text
.mdl ADDED
Binary file (44 Bytes). View file
 
.msc ADDED
Binary file (759 Bytes). View file
 
.mv ADDED
@@ -0,0 +1 @@
 
 
1
+ Revision:master,CreatedAt:1764209071
README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OBS-Diff Structured Pruning for Stable Diffusion-xl-base-1.0
2
+
3
+
4
+ ![](sdxl1.png)
5
+ ![](sdxl2.png)
6
+ ![](sdxl3.png)
7
+ ### Pruned UNet Variants
8
+ | Sparsity (%) | 0 (Dense) | 10 | 15 | 20 | 25 | 30 |
9
+ | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
10
+ | **Params (B)** | 2.57 | 2.35 | 2.24 | 2.13 | 2.02 | 1.91 |
11
+
12
+ ### How to use the pruned model
13
+
14
+ 1. Download the base model (SDXL) from [huggingface](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) or ModelScope.
15
+
16
+ 2. Download the pruned weights (.pth files) and use `torch.load` to replace the original UNet in the pipeline.
17
+
18
+ 3. Run inference using the code below.
19
+
20
+ ``` python
21
+ import os
22
+ import torch
23
+ from diffusers import DiffusionPipeline
24
+ from PIL import Image
25
+
26
+
27
+ # 1. Load the base SDXL model
28
+ pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
29
+
30
+ # 2. Swap the original UNet with the pruned UNet checkpoint
31
+ # Note: Ensure the path points to your downloaded .pth file
32
+ pruned_unet_path = "/path/to/sparsity_30/unet_pruned.pth"
33
+ pipe.unet = torch.load(pruned_unet_path, weights_only=False)
34
+ pipe = pipe.to("cuda")
35
+
36
+ total_params = sum(p.numel() for p in pipe.unet.parameters())
37
+ print(f"Total UNet parameters: {total_params / 1e6:.2f} M")
38
+
39
+ image = pipe(
40
+ prompt="A ship sailing through a sea of clouds, golden hour, impasto oil painting, brush strokes visible, dreamlike atmosphere.",
41
+ negative_prompt=None,
42
+ height=1024,
43
+ width=1024,
44
+ num_inference_steps=30,
45
+ guidance_scale=7.0,
46
+ generator=torch.Generator("cuda").manual_seed(42)
47
+ ).images[0]
48
+
49
+ image.save("output_pruned.png")
50
+
51
+ ```
configuration.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"framework":"Pytorch","task":"text-to-image-synthesis"}
sdxl1.png ADDED

Git LFS Details

  • SHA256: ba687fbf1eef2d3065dda1a781e9af76699805cc355ee470a2eb0d4bd9e1ef10
  • Pointer size: 132 Bytes
  • Size of remote file: 4.98 MB
sdxl2.png ADDED

Git LFS Details

  • SHA256: a5cc16c85bd90dc14d32c881ba6cb09d6ff7bddc9ddc80ed9b0d30a6a681fe3f
  • Pointer size: 132 Bytes
  • Size of remote file: 4.52 MB
sdxl3.png ADDED

Git LFS Details

  • SHA256: f7578d9516b05602aea22a75690251e168c1d668cab2bb3a1f965d26b3919deb
  • Pointer size: 132 Bytes
  • Size of remote file: 4.6 MB
sparsity_10/unet_pruned.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:835b4bd42874ebdf9bfe41d69ac0a35f30a7ee062a0cb4f1341723883f3e795a
3
+ size 4699003163
sparsity_15/unet_pruned.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab994c033322639a085f30de037a2a10478fd1bdf3743a8ab608ce5e4ac7c223
3
+ size 4475458027
sparsity_20/unet_pruned.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06c42b24f50227134ac7c2970aef3a0d9502dcdc95fd2f2176f975c22cf019ba
3
+ size 4262071263
sparsity_25/unet_pruned.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a061c65239480e465abe45122bff07b0515de529e7d957bee0f65af0f1a9b4e6
3
+ size 4048685023
sparsity_30/unet_pruned.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e15fc895c2c251dc2ef9ad2691c7f2428c5164b144290131b13c44beb58f851
3
+ size 3825140703