Krebzonide
commited on
Commit
·
ae9efe4
1
Parent(s):
133a145
Added refiner
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from diffusers import StableDiffusionXLPipeline, AutoencoderKL
|
2 |
import torch
|
3 |
import random
|
4 |
#from controlnet_aux import OpenposeDetector
|
@@ -9,8 +9,8 @@ import gradio as gr
|
|
9 |
model_base = "stabilityai/stable-diffusion-xl-base-1.0"
|
10 |
|
11 |
#model_url = "https://huggingface.co/Krebzonide/Colossus_Project_XL/blob/main/colossusProjectXLSFW_v202BakedVAE.safetensors"
|
12 |
-
|
13 |
-
|
14 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
15 |
|
16 |
#pipe = StableDiffusionXLPipeline.from_pretrained(
|
@@ -26,7 +26,15 @@ pipe = StableDiffusionXLPipeline.from_single_file(
|
|
26 |
scheduler_type = "ddim",
|
27 |
use_auth_token="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"
|
28 |
)
|
29 |
-
pipe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
css = """
|
32 |
.btn-green {
|
@@ -49,11 +57,18 @@ def generate(prompt, neg_prompt, samp_steps, guide_scale, batch_size, seed, heig
|
|
49 |
guidance_scale=guide_scale,
|
50 |
#cross_attention_kwargs={"scale": lora_scale},
|
51 |
num_images_per_prompt=batch_size,
|
52 |
-
height=height,
|
53 |
-
width=width,
|
54 |
generator=torch.manual_seed(seed),
|
55 |
).images
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
|
59 |
with gr.Blocks(css=css) as demo:
|
@@ -67,8 +82,8 @@ with gr.Blocks(css=css) as demo:
|
|
67 |
batch_size = gr.Slider(1, 6, value=1, step=1, label="Batch size")
|
68 |
with gr.Row():
|
69 |
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=999999, step=1)
|
70 |
-
height = gr.Slider(label="Height", value=1024,
|
71 |
-
width = gr.Slider(label="Width", value=1024,
|
72 |
gallery = gr.Gallery(label="Generated images", height=800)
|
73 |
|
74 |
submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed, height, width], [gallery], queue=True)
|
|
|
1 |
+
from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline, AutoencoderKL
|
2 |
import torch
|
3 |
import random
|
4 |
#from controlnet_aux import OpenposeDetector
|
|
|
9 |
model_base = "stabilityai/stable-diffusion-xl-base-1.0"
|
10 |
|
11 |
#model_url = "https://huggingface.co/Krebzonide/Colossus_Project_XL/blob/main/colossusProjectXLSFW_v202BakedVAE.safetensors"
|
12 |
+
model_url = "https://huggingface.co/Krebzonide/Sevenof9_v3_sdxl/blob/main/nsfwSevenof9V3_nsfwSevenof9V3.safetensors"
|
13 |
+
|
14 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
15 |
|
16 |
#pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
|
26 |
scheduler_type = "ddim",
|
27 |
use_auth_token="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"
|
28 |
)
|
29 |
+
pipe.enable_model_cpu_offload()
|
30 |
+
|
31 |
+
pipeRefiner = StableDiffusionXLImg2ImgPipeline.from_pretrained(
|
32 |
+
"stabilityai/stable-diffusion-xl-refiner-1.0",
|
33 |
+
torch_dtype=torch.float16,
|
34 |
+
variant="fp16",
|
35 |
+
use_safetensors=True
|
36 |
+
)
|
37 |
+
pipeRefiner.enable_model_cpu_offload()
|
38 |
|
39 |
css = """
|
40 |
.btn-green {
|
|
|
57 |
guidance_scale=guide_scale,
|
58 |
#cross_attention_kwargs={"scale": lora_scale},
|
59 |
num_images_per_prompt=batch_size,
|
60 |
+
height=height/2,
|
61 |
+
width=width/2,
|
62 |
generator=torch.manual_seed(seed),
|
63 |
).images
|
64 |
+
imagesRefined = pipeRefiner(
|
65 |
+
prompt,
|
66 |
+
image=images,
|
67 |
+
num_inference_steps=5,
|
68 |
+
height=height,
|
69 |
+
width=width
|
70 |
+
).images
|
71 |
+
return [(img, f"Image {i+1}") for i, img in enumerate(imagesRefined)]
|
72 |
|
73 |
|
74 |
with gr.Blocks(css=css) as demo:
|
|
|
82 |
batch_size = gr.Slider(1, 6, value=1, step=1, label="Batch size")
|
83 |
with gr.Row():
|
84 |
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=999999, step=1)
|
85 |
+
height = gr.Slider(label="Height", value=1024, minimum=512, maximum=2048, step=16)
|
86 |
+
width = gr.Slider(label="Width", value=1024, minimum=512, maximum=2048, step=16)
|
87 |
gallery = gr.Gallery(label="Generated images", height=800)
|
88 |
|
89 |
submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed, height, width], [gallery], queue=True)
|