Spaces:
Running
on
Zero
Running
on
Zero
scheduler
Browse files
app.py
CHANGED
@@ -7,7 +7,13 @@ import math
|
|
7 |
import torch
|
8 |
import numpy as np
|
9 |
|
10 |
-
from diffusers import
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
12 |
|
13 |
import gradio as gr
|
@@ -43,11 +49,14 @@ dart = dart.requires_grad_(False)
|
|
43 |
dart = torch.compile(dart)
|
44 |
tokenizer = AutoTokenizer.from_pretrained(DART_V3_REPO_ID)
|
45 |
|
46 |
-
pipe =
|
47 |
IMAGE_MODEL_REPO_ID,
|
48 |
torch_dtype=torch_dtype,
|
|
|
49 |
custom_pipeline="lpw_stable_diffusion_xl"
|
50 |
)
|
|
|
|
|
51 |
pipe = pipe.to(device)
|
52 |
|
53 |
|
@@ -189,16 +198,14 @@ with gr.Blocks(css=css) as demo:
|
|
189 |
with gr.Accordion("Advanced Settings", open=False):
|
190 |
prompt_suffix = gr.Text(
|
191 |
label="Prompt suffix",
|
192 |
-
|
193 |
-
|
194 |
-
value="masterpiece, best quality",
|
195 |
)
|
196 |
negative_prompt = gr.Text(
|
197 |
label="Negative prompt",
|
198 |
-
max_lines=1,
|
199 |
placeholder="Enter a negative prompt",
|
200 |
-
visible=
|
201 |
-
value="worst quality, bad quality, low quality, lowres, displeasing, very displeasing, bad anatomy, bad hands, scan artifacts, signature, username, jpeg artifacts,
|
202 |
)
|
203 |
|
204 |
seed = gr.Slider(
|
@@ -214,18 +221,18 @@ with gr.Blocks(css=css) as demo:
|
|
214 |
with gr.Row():
|
215 |
width = gr.Slider(
|
216 |
label="Width",
|
217 |
-
minimum=
|
218 |
maximum=MAX_IMAGE_SIZE,
|
219 |
-
step=
|
220 |
-
value=
|
221 |
)
|
222 |
|
223 |
height = gr.Slider(
|
224 |
label="Height",
|
225 |
-
minimum=
|
226 |
maximum=MAX_IMAGE_SIZE,
|
227 |
-
step=
|
228 |
-
value=
|
229 |
)
|
230 |
|
231 |
with gr.Row():
|
@@ -234,15 +241,15 @@ with gr.Blocks(css=css) as demo:
|
|
234 |
minimum=1.0,
|
235 |
maximum=10.0,
|
236 |
step=0.5,
|
237 |
-
value=
|
238 |
)
|
239 |
|
240 |
num_inference_steps = gr.Slider(
|
241 |
label="Number of inference steps",
|
242 |
-
minimum=
|
243 |
maximum=50,
|
244 |
step=1,
|
245 |
-
value=
|
246 |
)
|
247 |
|
248 |
gr.on(
|
|
|
7 |
import torch
|
8 |
import numpy as np
|
9 |
|
10 |
+
from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl import (
|
11 |
+
StableDiffusionXLPipeline,
|
12 |
+
)
|
13 |
+
from diffusers.schedulers.scheduling_euler_ancestral_discrete import (
|
14 |
+
EulerAncestralDiscreteScheduler,
|
15 |
+
)
|
16 |
+
from diffusers.models.attention_processor import AttnProcessor2_0
|
17 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
18 |
|
19 |
import gradio as gr
|
|
|
49 |
dart = torch.compile(dart)
|
50 |
tokenizer = AutoTokenizer.from_pretrained(DART_V3_REPO_ID)
|
51 |
|
52 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
53 |
IMAGE_MODEL_REPO_ID,
|
54 |
torch_dtype=torch_dtype,
|
55 |
+
add_watermarker=False,
|
56 |
custom_pipeline="lpw_stable_diffusion_xl"
|
57 |
)
|
58 |
+
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
59 |
+
pipe.unet.set_attn_processor(AttnProcessor2_0())
|
60 |
pipe = pipe.to(device)
|
61 |
|
62 |
|
|
|
198 |
with gr.Accordion("Advanced Settings", open=False):
|
199 |
prompt_suffix = gr.Text(
|
200 |
label="Prompt suffix",
|
201 |
+
visible=True,
|
202 |
+
value="masterpiece, best quality, very aesthetic",
|
|
|
203 |
)
|
204 |
negative_prompt = gr.Text(
|
205 |
label="Negative prompt",
|
|
|
206 |
placeholder="Enter a negative prompt",
|
207 |
+
visible=True,
|
208 |
+
value="(worst quality, bad quality, low quality:1.2), lowres, displeasing, very displeasing, bad anatomy, bad hands, extra digits, fewer digits, scan artifacts, signature, username, jpeg artifacts, retro, 2010s",
|
209 |
)
|
210 |
|
211 |
seed = gr.Slider(
|
|
|
221 |
with gr.Row():
|
222 |
width = gr.Slider(
|
223 |
label="Width",
|
224 |
+
minimum=512,
|
225 |
maximum=MAX_IMAGE_SIZE,
|
226 |
+
step=64,
|
227 |
+
value=832, # Replace with defaults that work for your model
|
228 |
)
|
229 |
|
230 |
height = gr.Slider(
|
231 |
label="Height",
|
232 |
+
minimum=512,
|
233 |
maximum=MAX_IMAGE_SIZE,
|
234 |
+
step=64,
|
235 |
+
value=1152, # Replace with defaults that work for your model
|
236 |
)
|
237 |
|
238 |
with gr.Row():
|
|
|
241 |
minimum=1.0,
|
242 |
maximum=10.0,
|
243 |
step=0.5,
|
244 |
+
value=7,
|
245 |
)
|
246 |
|
247 |
num_inference_steps = gr.Slider(
|
248 |
label="Number of inference steps",
|
249 |
+
minimum=20,
|
250 |
maximum=50,
|
251 |
step=1,
|
252 |
+
value=25,
|
253 |
)
|
254 |
|
255 |
gr.on(
|