Spaces:
Runtime error
Runtime error
Delete huggingface_hub.py
Browse files- huggingface_hub.py +0 -28
huggingface_hub.py
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
from huggingface_hub import hf_hub_download
|
2 |
-
from safetensors.torch import load_file
|
3 |
-
from diffusers import StableDiffusionPipeline
|
4 |
-
|
5 |
-
def load_pipeline(base_model_path, lora_repo_id, lora_filename):
|
6 |
-
# Load the base SD pipeline
|
7 |
-
pipeline = StableDiffusionPipeline.from_pretrained(base_model_path)
|
8 |
-
|
9 |
-
# Download the LoRA file
|
10 |
-
lora_path = hf_hub_download(repo_id=lora_repo_id, filename=lora_filename)
|
11 |
-
|
12 |
-
# Load the LoRA weights
|
13 |
-
lora_state_dict = load_file(lora_path)
|
14 |
-
pipeline.unet.load_attn_procs(lora_state_dict)
|
15 |
-
|
16 |
-
return pipeline
|
17 |
-
|
18 |
-
# Define parameters
|
19 |
-
base_model_path = "runwayml/stable-diffusion-v1-5"
|
20 |
-
lora_repo_id = "maria26/Floor_Plan_LoRA"
|
21 |
-
lora_filename = "model.safetensors"
|
22 |
-
|
23 |
-
# Load the pipeline
|
24 |
-
pipeline = load_pipeline(base_model_path, lora_repo_id, lora_filename)
|
25 |
-
|
26 |
-
def predict(prompt):
|
27 |
-
result = pipeline(prompt).images[0]
|
28 |
-
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|