Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import numpy as np
|
|
| 3 |
import random
|
| 4 |
|
| 5 |
from diffusers import DiffusionPipeline
|
|
|
|
| 6 |
import torch
|
| 7 |
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -39,10 +40,8 @@ def load_pipeline(model_id: str):
|
|
| 39 |
base_model = "CompVis/stable-diffusion-v1-4"
|
| 40 |
pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch_dtype)
|
| 41 |
# Load the LoRA weights into the U-Net.
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
pipe.load_lora_weights(model_id, weight_name="text_encoder/adapter_model.safetensors")
|
| 45 |
-
pipe.load_lora_weights(model_id, weight_name="unet/adapter_model.safetensors")
|
| 46 |
else:
|
| 47 |
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch_dtype)
|
| 48 |
|
|
|
|
| 3 |
import random
|
| 4 |
|
| 5 |
from diffusers import DiffusionPipeline
|
| 6 |
+
from peft import PeftModel, PeftConfig
|
| 7 |
import torch
|
| 8 |
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 40 |
base_model = "CompVis/stable-diffusion-v1-4"
|
| 41 |
pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch_dtype)
|
| 42 |
# Load the LoRA weights into the U-Net.
|
| 43 |
+
pipe.unet = PeftModel.from_pretrained(pipe.unet, "unet")
|
| 44 |
+
|
|
|
|
|
|
|
| 45 |
else:
|
| 46 |
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch_dtype)
|
| 47 |
|