Spaces:
Runtime error
Runtime error
Commit
Β·
11973fd
1
Parent(s):
19e5cfb
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -27,24 +27,22 @@ import gc
|
|
| 27 |
gc.collect()
|
| 28 |
torch.cuda.empty_cache()
|
| 29 |
|
| 30 |
-
|
| 31 |
-
vae = AutoencoderKL.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="vae")
|
| 32 |
|
| 33 |
-
|
| 34 |
-
tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14")
|
| 35 |
-
text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14")
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear",
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
# To the GPU we go!
|
| 45 |
-
vae = vae.to(torch_device)
|
| 46 |
-
text_encoder = text_encoder.to(torch_device)
|
| 47 |
-
unet = unet.to(torch_device)
|
| 48 |
|
| 49 |
seed_values = [0, 0, 0, 0, 0]
|
| 50 |
|
|
|
|
| 27 |
gc.collect()
|
| 28 |
torch.cuda.empty_cache()
|
| 29 |
|
| 30 |
+
from diffusers import StableDiffusionPipeline
|
|
|
|
| 31 |
|
| 32 |
+
model_id = "segmind/tiny-sd"
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id).to("cpu")
|
| 35 |
+
text_encoder = pipe.text_encoder.to(torch_device)
|
| 36 |
+
text_encoder.eval()
|
| 37 |
+
unet = pipe.unet.to(torch_device)
|
| 38 |
+
unet.eval()
|
| 39 |
+
vae = pipe.vae.to(torch_device)
|
| 40 |
+
vae.eval()
|
| 41 |
|
| 42 |
+
tokenizer = CLIPTokenizer.from_pretrained('openai/clip-vit-large-patch14')
|
| 43 |
+
scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
|
| 44 |
+
del pipe
|
| 45 |
+
gc.collect()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
seed_values = [0, 0, 0, 0, 0]
|
| 48 |
|