Update app.py
Browse files
app.py
CHANGED
|
@@ -69,7 +69,6 @@ pipe = StableDiffusion3Pipeline.from_pretrained("ford442/stable-diffusion-3.5-me
|
|
| 69 |
|
| 70 |
pipe.load_lora_weights('ford442/sdxl-vae-bf16', weight_name='LoRA/bm-goth_epoch_9.safetensors')
|
| 71 |
|
| 72 |
-
pipe.to(device=device, dtype=torch.bfloat16)
|
| 73 |
|
| 74 |
#pipe = StableDiffusion3Pipeline.from_pretrained("ford442/stable-diffusion-3.5-medium-bf16").to(torch.device("cuda:0"))
|
| 75 |
#pipe = StableDiffusion3Pipeline.from_pretrained("ford442/RealVis_Medium_1.0b_bf16", torch_dtype=torch.bfloat16)
|
|
@@ -172,6 +171,15 @@ def infer(
|
|
| 172 |
attention_mask_2 = encoded_inputs_2["attention_mask"].to(device)
|
| 173 |
print("-- tokenize prompt --")
|
| 174 |
# Google T5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
#input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
| 176 |
outputs = model.generate(
|
| 177 |
input_ids=input_ids,
|
|
|
|
| 69 |
|
| 70 |
pipe.load_lora_weights('ford442/sdxl-vae-bf16', weight_name='LoRA/bm-goth_epoch_9.safetensors')
|
| 71 |
|
|
|
|
| 72 |
|
| 73 |
#pipe = StableDiffusion3Pipeline.from_pretrained("ford442/stable-diffusion-3.5-medium-bf16").to(torch.device("cuda:0"))
|
| 74 |
#pipe = StableDiffusion3Pipeline.from_pretrained("ford442/RealVis_Medium_1.0b_bf16", torch_dtype=torch.bfloat16)
|
|
|
|
| 171 |
attention_mask_2 = encoded_inputs_2["attention_mask"].to(device)
|
| 172 |
print("-- tokenize prompt --")
|
| 173 |
# Google T5
|
| 174 |
+
if expanded_only:
|
| 175 |
+
pipe.to('cpu')
|
| 176 |
+
torch.cuda.empty_cache()
|
| 177 |
+
torch.cuda.reset_peak_memory_stats()
|
| 178 |
+
else:
|
| 179 |
+
torch.cuda.empty_cache()
|
| 180 |
+
torch.cuda.reset_peak_memory_stats()
|
| 181 |
+
pipe.to(device=device, dtype=torch.bfloat16)
|
| 182 |
+
gc.collect()
|
| 183 |
#input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
| 184 |
outputs = model.generate(
|
| 185 |
input_ids=input_ids,
|