ChenHe727 commited on
Commit
aef6fd1
·
verified ·
1 Parent(s): 9f3b6d6

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +50 -0
README.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EdgeDiffusion - Distilled
2
+
3
+ A pruned and distilled Stable Diffusion 1.5 UNet (647.2M params, ~25% smaller than original 858.5M).
4
+
5
+ ## Pipeline
6
+
7
+ 1. **Iterative Pruning**: 4 rounds of ~7% Taylor-importance pruning (858.5M → 647.2M)
8
+ 2. **Knowledge Distillation**: 15K steps with Realistic Vision v5.1 as teacher (feature + noise MSE loss)
9
+
10
+ ## Files
11
+
12
+ | File | Description |
13
+ |------|-------------|
14
+ | `pruned_unet.safetensors` | Pruned + distilled UNet weights |
15
+ | `pruned_unet.config.json` | Model config (contains `model_config` for rebuilding) |
16
+ | `pruned_rebuild.py` | Script to rebuild the pruned UNet architecture |
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ # 1. Download all 3 files to the same directory, then:
22
+ from pruned_rebuild import create_unet_from_safetensors
23
+ from diffusers import StableDiffusionPipeline
24
+ import torch
25
+
26
+ # 2. Rebuild the pruned UNet
27
+ unet = create_unet_from_safetensors(
28
+ "pruned_unet.safetensors",
29
+ "pruned_unet.config.json"
30
+ )
31
+
32
+ # 3. Load into a standard SD 1.5 pipeline
33
+ pipe = StableDiffusionPipeline.from_pretrained(
34
+ "runwayml/stable-diffusion-v1-5",
35
+ unet=unet,
36
+ torch_dtype=torch.float16,
37
+ safety_checker=None,
38
+ )
39
+ pipe = pipe.to("cuda")
40
+
41
+ # 4. Generate
42
+ image = pipe("a beautiful sunset over mountains", num_inference_steps=30).images[0]
43
+ image.save("output.png")
44
+ ```
45
+
46
+ ## Requirements
47
+
48
+ ```
49
+ pip install diffusers transformers safetensors torch accelerate
50
+ ```