Spaces:
Sleeping
Sleeping
George Krupenchenkov
commited on
Commit
·
7c45782
1
Parent(s):
3264bf1
add device
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import random
|
|
4 |
import gradio as gr
|
5 |
import numpy as np
|
6 |
import torch
|
7 |
-
|
8 |
# import spaces #[uncomment to use ZeroGPU]
|
9 |
from diffusers import StableDiffusionPipeline
|
10 |
from peft import LoraConfig, PeftModel
|
@@ -60,7 +59,7 @@ def get_lora_sd_pipeline(
|
|
60 |
|
61 |
pipe = StableDiffusionPipeline.from_pretrained(
|
62 |
base_model_name_or_path, torch_dtype=dtype
|
63 |
-
)
|
64 |
pipe.unet = PeftModel.from_pretrained(
|
65 |
pipe.unet, unet_sub_dir, adapter_name=adapter_name
|
66 |
)
|
@@ -101,7 +100,7 @@ def infer(
|
|
101 |
# добавляем lora
|
102 |
pipe = get_lora_sd_pipeline(
|
103 |
os.path.join(CKPT_DIR, ""), adapter_name="sd-14-lora", dtype=torch_dtype
|
104 |
-
)
|
105 |
pipe.safety_checker = None
|
106 |
print(f"LoRA adapter loaded: {pipe.unet.active_adapters}")
|
107 |
|
@@ -112,7 +111,7 @@ def infer(
|
|
112 |
requires_safety_checker=False,
|
113 |
safety_checker=None,
|
114 |
)
|
115 |
-
pipe = pipe
|
116 |
|
117 |
image = pipe(
|
118 |
prompt=prompt,
|
|
|
4 |
import gradio as gr
|
5 |
import numpy as np
|
6 |
import torch
|
|
|
7 |
# import spaces #[uncomment to use ZeroGPU]
|
8 |
from diffusers import StableDiffusionPipeline
|
9 |
from peft import LoraConfig, PeftModel
|
|
|
59 |
|
60 |
pipe = StableDiffusionPipeline.from_pretrained(
|
61 |
base_model_name_or_path, torch_dtype=dtype
|
62 |
+
).to(device)
|
63 |
pipe.unet = PeftModel.from_pretrained(
|
64 |
pipe.unet, unet_sub_dir, adapter_name=adapter_name
|
65 |
)
|
|
|
100 |
# добавляем lora
|
101 |
pipe = get_lora_sd_pipeline(
|
102 |
os.path.join(CKPT_DIR, ""), adapter_name="sd-14-lora", dtype=torch_dtype
|
103 |
+
).to(device)
|
104 |
pipe.safety_checker = None
|
105 |
print(f"LoRA adapter loaded: {pipe.unet.active_adapters}")
|
106 |
|
|
|
111 |
requires_safety_checker=False,
|
112 |
safety_checker=None,
|
113 |
)
|
114 |
+
pipe = pipe.to(device)
|
115 |
|
116 |
image = pipe(
|
117 |
prompt=prompt,
|