Papadizzy commited on
Commit
d833453
·
verified ·
1 Parent(s): ab55bcb

Create setup.py

Browse files
Files changed (1) hide show
  1. setup.py +28 -0
setup.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # setup.py
2
+ """
3
+ This script runs automatically when the Space is built.
4
+ It pulls the entire SDXL‑i2i repo into the cache so the runtime never
5
+ has to hit the Hub again.
6
+ """
7
+
8
+ import os
9
+ import torch
10
+ from diffusers import StableDiffusionXLImg2ImgPipeline
11
+
12
+ MODEL_ID = "stabilityai/stable-diffusion-xl-1.0"
13
+
14
+ def download():
15
+ print(f"[setup] Downloading {MODEL_ID}…")
16
+ # CPU‑friendly download; the full checkpoint (~10 GB) will be cached
17
+ StableDiffusionXLImg2ImgPipeline.from_pretrained(
18
+ MODEL_ID,
19
+ torch_dtype=torch.float32, # no GPU needed for the download
20
+ use_safetensors=True,
21
+ variant=None, # 0.x repo, no special variant
22
+ )
23
+ print("[setup] ✅ Download finished")
24
+
25
+ if __name__ == "__main__":
26
+ # Ensure the cache lives in the default location
27
+ # (you can change HF_HOME or HUGGINGFACE_HUB_CACHE if you want)
28
+ download()