Update handler.py
Browse files- handler.py +7 -2
handler.py
CHANGED
|
@@ -8,7 +8,7 @@ class EndpointHandler:
|
|
| 8 |
def __init__(self, path: str = ""):
|
| 9 |
print(f"Initializing SDXL model from: {path}")
|
| 10 |
|
| 11 |
-
#
|
| 12 |
self.pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 13 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 14 |
torch_dtype=torch.float16,
|
|
@@ -16,7 +16,12 @@ class EndpointHandler:
|
|
| 16 |
)
|
| 17 |
|
| 18 |
print("Loading LoRA weights from: Texttra/Bh0r")
|
| 19 |
-
self.pipe.load_lora_weights(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
self.pipe.fuse_lora()
|
| 21 |
|
| 22 |
self.pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
| 8 |
def __init__(self, path: str = ""):
|
| 9 |
print(f"Initializing SDXL model from: {path}")
|
| 10 |
|
| 11 |
+
# Load the base SDXL model
|
| 12 |
self.pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 13 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 14 |
torch_dtype=torch.float16,
|
|
|
|
| 16 |
)
|
| 17 |
|
| 18 |
print("Loading LoRA weights from: Texttra/Bh0r")
|
| 19 |
+
self.pipe.load_lora_weights(
|
| 20 |
+
"Texttra/Bh0r",
|
| 21 |
+
weight_name="Bh0r-10.safetensors",
|
| 22 |
+
adapter_name="bh0r_lora"
|
| 23 |
+
)
|
| 24 |
+
self.pipe.set_adapters(["bh0r_lora"], adapter_weights=[0.9])
|
| 25 |
self.pipe.fuse_lora()
|
| 26 |
|
| 27 |
self.pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|