Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,31 @@
|
|
1 |
-
|
2 |
-
from
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
model_name = "maria26/Floor_Plan_LoRA"
|
8 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
10 |
-
model.eval()
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
# Define Gradio interface
|
24 |
interface = gr.Interface(fn=predict, inputs="text", outputs="image")
|
25 |
-
interface.launch()
|
|
|
1 |
+
from diffusers import StableDiffusionPipeline
|
2 |
+
from safetensors.torch import load_file
|
3 |
+
import torch
|
4 |
+
|
5 |
+
def load_pipeline(base_model_path, lora_path):
|
6 |
+
# Load base SD-v1.5 pipeline
|
7 |
+
pipeline = StableDiffusionPipeline.from_pretrained(base_model_path)
|
8 |
+
|
9 |
+
# Load LoRA weights
|
10 |
+
lora_state_dict = load_file(lora_path)
|
11 |
+
pipeline.unet.load_attn_procs(lora_state_dict)
|
12 |
|
13 |
+
return pipeline
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
# Paths to the base model and LoRA weights
|
16 |
+
base_model_path = "path/to/sd-v1-5"
|
17 |
+
lora_path = "path/to/Floor_Plan_LoRA.safetensors"
|
18 |
|
19 |
+
# Load the pipeline
|
20 |
+
pipeline = load_pipeline(base_model_path, lora_path)
|
21 |
|
22 |
+
def predict(prompt):
|
23 |
+
# Generate an image based on the prompt
|
24 |
+
result = pipeline(prompt).images[0]
|
25 |
+
return result
|
26 |
+
|
27 |
+
# Create Gradio Interface
|
28 |
+
import gradio as gr
|
29 |
|
|
|
30 |
interface = gr.Interface(fn=predict, inputs="text", outputs="image")
|
31 |
+
interface.launch()
|