Krebzonide
commited on
Commit
·
fae7b1e
1
Parent(s):
0428186
Update app.py
Browse files
app.py
CHANGED
@@ -6,12 +6,13 @@ import random
|
|
6 |
import gradio as gr
|
7 |
import gc
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
#
|
13 |
-
|
14 |
-
|
|
|
15 |
|
16 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
17 |
pipe = None
|
@@ -61,19 +62,8 @@ def set_base_model(base_model_id):
|
|
61 |
use_safetensors = True,
|
62 |
use_auth_token="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"
|
63 |
)
|
64 |
-
#pipe = load_model(base_model_id)
|
65 |
pipe.to("cuda")
|
66 |
return pipe
|
67 |
-
|
68 |
-
def load_model(base_model_id):
|
69 |
-
pipe = StableDiffusionXLPipeline.from_single_file(
|
70 |
-
model_url,
|
71 |
-
torch_dtype = torch.float16,
|
72 |
-
variant = "fp16",
|
73 |
-
vae = vae,
|
74 |
-
use_safetensors = True,
|
75 |
-
use_auth_token="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"
|
76 |
-
)
|
77 |
|
78 |
|
79 |
with gr.Blocks(css=css) as demo:
|
@@ -90,9 +80,13 @@ with gr.Blocks(css=css) as demo:
|
|
90 |
height = gr.Slider(label="Height", value=1024, minimum=512, maximum=2048, step=16)
|
91 |
width = gr.Slider(label="Width", value=1024, minimum=512, maximum=2048, step=16)
|
92 |
gallery = gr.Gallery(label="Generated images", height=800)
|
|
|
|
|
|
|
93 |
|
94 |
submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed, height, width], [gallery], queue=True)
|
|
|
95 |
|
96 |
-
pipe = set_base_model(
|
97 |
demo.queue(1)
|
98 |
demo.launch(debug=True)
|
|
|
6 |
import gradio as gr
|
7 |
import gc
|
8 |
|
9 |
+
model_list = ["stabilityai/stable-diffusion-xl-base-1.0",
|
10 |
+
"Colossus_Project_XL",
|
11 |
+
"Sevenof9_v3_sdxl"]
|
12 |
+
#add "https://huggingface.co/" before the url
|
13 |
+
model_url_list = ["stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors",
|
14 |
+
"Krebzonide/Colossus_Project_XL/blob/main/colossusProjectXLSFW_v202BakedVAE.safetensors",
|
15 |
+
"Krebzonide/Sevenof9_v3_sdxl/blob/main/nsfwSevenof9V3_nsfwSevenof9V3.safetensors"]
|
16 |
|
17 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
18 |
pipe = None
|
|
|
62 |
use_safetensors = True,
|
63 |
use_auth_token="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"
|
64 |
)
|
|
|
65 |
pipe.to("cuda")
|
66 |
return pipe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
|
69 |
with gr.Blocks(css=css) as demo:
|
|
|
80 |
height = gr.Slider(label="Height", value=1024, minimum=512, maximum=2048, step=16)
|
81 |
width = gr.Slider(label="Width", value=1024, minimum=512, maximum=2048, step=16)
|
82 |
gallery = gr.Gallery(label="Generated images", height=800)
|
83 |
+
with gr.Row():
|
84 |
+
model_id = gr.Dropdown(model_list, label="model")
|
85 |
+
change_model_btn = gr.Button("Update Model", elem_classes="btn-green")
|
86 |
|
87 |
submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed, height, width], [gallery], queue=True)
|
88 |
+
change_model_btn.click(set_base_model, [model_id], queue = false)
|
89 |
|
90 |
+
pipe = set_base_model(model_list[0])
|
91 |
demo.queue(1)
|
92 |
demo.launch(debug=True)
|