Update app.py
Browse files
app.py
CHANGED
@@ -3,20 +3,20 @@ from diffusers import LCMScheduler, AutoPipelineForText2Image,DDPMScheduler
|
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
5 |
import gradio as gr
|
|
|
|
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
12 |
-
adapter_id = "ksyint/teu_lora"
|
13 |
-
|
14 |
-
pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float32, variant="fp16")
|
15 |
-
pipe.scheduler = DDPMScheduler.from_config(pipe.scheduler.config)
|
16 |
-
pipe.to("cpu")
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
|
21 |
image = pipe(prompt=prompt, num_inference_steps=num_steps, guidance_scale=5.0,strength=5.0).images[0]
|
22 |
#gc.collect()
|
@@ -24,7 +24,7 @@ def main(prompt,num_steps):
|
|
24 |
return image
|
25 |
|
26 |
|
27 |
-
iface = gr.Interface(fn=main, inputs=["text"
|
28 |
description="Generate images based on textual prompts.")
|
29 |
if __name__ == "__main__":
|
30 |
|
|
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
5 |
import gradio as gr
|
6 |
+
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
7 |
+
adapter_id = "ksyint/teu_lora"
|
8 |
|
9 |
+
pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float32, variant="fp16")
|
10 |
+
pipe.scheduler = DDPMScheduler.from_config(pipe.scheduler.config)
|
11 |
+
pipe.to("cpu")
|
12 |
|
13 |
+
pipe.load_lora_weights(adapter_id)
|
14 |
+
pipe.fuse_lora()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
def main(prompt):
|
17 |
+
num_steps=60
|
18 |
+
|
19 |
+
|
20 |
|
21 |
image = pipe(prompt=prompt, num_inference_steps=num_steps, guidance_scale=5.0,strength=5.0).images[0]
|
22 |
#gc.collect()
|
|
|
24 |
return image
|
25 |
|
26 |
|
27 |
+
iface = gr.Interface(fn=main, inputs=["text"], outputs="image", title="Text to Image Generation",
|
28 |
description="Generate images based on textual prompts.")
|
29 |
if __name__ == "__main__":
|
30 |
|