Spaces:
Running
on
Zero
Running
on
Zero
kayfahaarukku
commited on
Commit
•
b4f0b46
1
Parent(s):
7740751
Update app.py
Browse files
app.py
CHANGED
@@ -11,14 +11,14 @@ tqdm.monitor_interval = 0
|
|
11 |
|
12 |
# Load the diffusion pipelines
|
13 |
pipe1 = StableDiffusionXLPipeline.from_pretrained(
|
14 |
-
"kayfahaarukku/UrangDiffusion-1.
|
15 |
torch_dtype=torch.float16,
|
16 |
custom_pipeline="lpw_stable_diffusion_xl",
|
17 |
)
|
18 |
pipe1.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe1.scheduler.config)
|
19 |
|
20 |
pipe2 = StableDiffusionXLPipeline.from_pretrained(
|
21 |
-
"kayfahaarukku/UrangDiffusion-
|
22 |
torch_dtype=torch.float16,
|
23 |
custom_pipeline="lpw_stable_diffusion_xl",
|
24 |
)
|
@@ -33,7 +33,7 @@ def generate_comparison(prompt, negative_prompt, use_defaults, resolution, guida
|
|
33 |
if randomize_seed:
|
34 |
seed = random.randint(0, 99999999)
|
35 |
if use_defaults:
|
36 |
-
prompt = f"{prompt},
|
37 |
negative_prompt = f"nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract], {negative_prompt}"
|
38 |
generator = torch.manual_seed(seed)
|
39 |
|
@@ -43,7 +43,7 @@ def generate_comparison(prompt, negative_prompt, use_defaults, resolution, guida
|
|
43 |
|
44 |
width, height = map(int, resolution.split('x'))
|
45 |
|
46 |
-
# Generate image with UrangDiffusion-1.
|
47 |
image1 = pipe1(
|
48 |
prompt,
|
49 |
negative_prompt=negative_prompt,
|
@@ -56,7 +56,7 @@ def generate_comparison(prompt, negative_prompt, use_defaults, resolution, guida
|
|
56 |
callback_steps=1
|
57 |
).images[0]
|
58 |
|
59 |
-
# Generate image with UrangDiffusion-
|
60 |
image2 = pipe2(
|
61 |
prompt,
|
62 |
negative_prompt=negative_prompt,
|
@@ -81,12 +81,12 @@ def interface_fn(prompt, negative_prompt, use_defaults, resolution, guidance_sca
|
|
81 |
return image1, image2, seed, gr.update(value=metadata_text)
|
82 |
|
83 |
def reset_inputs():
|
84 |
-
return gr.update(value=''), gr.update(value=''), gr.update(value=True), gr.update(value='
|
85 |
|
86 |
with gr.Blocks(title="UrangDiffusion Comparison Demo", theme="NoCrypt/miku@1.2.1") as demo:
|
87 |
gr.HTML(
|
88 |
-
"<h1>UrangDiffusion 1.
|
89 |
-
"This demo showcases a comparison between UrangDiffusion 1.
|
90 |
)
|
91 |
with gr.Row():
|
92 |
with gr.Column():
|
@@ -99,19 +99,19 @@ with gr.Blocks(title="UrangDiffusion Comparison Demo", theme="NoCrypt/miku@1.2.1
|
|
99 |
"1344x768", "768x1344", "1536x640", "640x1536"
|
100 |
],
|
101 |
label="Resolution",
|
102 |
-
value="
|
103 |
)
|
104 |
-
guidance_scale_input = gr.Slider(minimum=1, maximum=20, step=0.5, label="Guidance Scale", value=
|
105 |
-
num_inference_steps_input = gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=
|
106 |
-
seed_input = gr.Slider(minimum=0, maximum=
|
107 |
randomize_seed_input = gr.Checkbox(label="Randomize Seed", value=True)
|
108 |
generate_button = gr.Button("Generate Comparison")
|
109 |
reset_button = gr.Button("Reset")
|
110 |
|
111 |
with gr.Column():
|
112 |
with gr.Row():
|
113 |
-
output_image1 = gr.Image(type="pil", label="UrangDiffusion 1.
|
114 |
-
output_image2 = gr.Image(type="pil", label="UrangDiffusion
|
115 |
with gr.Accordion("Parameters", open=False):
|
116 |
gr.Markdown(
|
117 |
"""
|
@@ -122,9 +122,9 @@ with gr.Blocks(title="UrangDiffusion Comparison Demo", theme="NoCrypt/miku@1.2.1
|
|
122 |
gr.Markdown(
|
123 |
"""
|
124 |
### Recommended prompt formatting:
|
125 |
-
`1girl/1boy, character name, from what series, everything else in any order,
|
126 |
|
127 |
-
**PS:** `
|
128 |
|
129 |
### Recommended settings:
|
130 |
- Steps: 25-30
|
|
|
11 |
|
12 |
# Load the diffusion pipelines
|
13 |
pipe1 = StableDiffusionXLPipeline.from_pretrained(
|
14 |
+
"kayfahaarukku/UrangDiffusion-1.4",
|
15 |
torch_dtype=torch.float16,
|
16 |
custom_pipeline="lpw_stable_diffusion_xl",
|
17 |
)
|
18 |
pipe1.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe1.scheduler.config)
|
19 |
|
20 |
pipe2 = StableDiffusionXLPipeline.from_pretrained(
|
21 |
+
"kayfahaarukku/UrangDiffusion-2.0",
|
22 |
torch_dtype=torch.float16,
|
23 |
custom_pipeline="lpw_stable_diffusion_xl",
|
24 |
)
|
|
|
33 |
if randomize_seed:
|
34 |
seed = random.randint(0, 99999999)
|
35 |
if use_defaults:
|
36 |
+
prompt = f"{prompt}, best quality, amazing quality, very aesthetic"
|
37 |
negative_prompt = f"nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract], {negative_prompt}"
|
38 |
generator = torch.manual_seed(seed)
|
39 |
|
|
|
43 |
|
44 |
width, height = map(int, resolution.split('x'))
|
45 |
|
46 |
+
# Generate image with UrangDiffusion-1.4
|
47 |
image1 = pipe1(
|
48 |
prompt,
|
49 |
negative_prompt=negative_prompt,
|
|
|
56 |
callback_steps=1
|
57 |
).images[0]
|
58 |
|
59 |
+
# Generate image with UrangDiffusion-2.0
|
60 |
image2 = pipe2(
|
61 |
prompt,
|
62 |
negative_prompt=negative_prompt,
|
|
|
81 |
return image1, image2, seed, gr.update(value=metadata_text)
|
82 |
|
83 |
def reset_inputs():
|
84 |
+
return gr.update(value=''), gr.update(value=''), gr.update(value=True), gr.update(value='832x1216'), gr.update(value=7), gr.update(value=28), gr.update(value=0), gr.update(value=True), gr.update(value='')
|
85 |
|
86 |
with gr.Blocks(title="UrangDiffusion Comparison Demo", theme="NoCrypt/miku@1.2.1") as demo:
|
87 |
gr.HTML(
|
88 |
+
"<h1>UrangDiffusion 1.4 vs 2.0 Comparison Demo</h1>"
|
89 |
+
"This demo showcases a comparison between UrangDiffusion 1.4 and 2.0."
|
90 |
)
|
91 |
with gr.Row():
|
92 |
with gr.Column():
|
|
|
99 |
"1344x768", "768x1344", "1536x640", "640x1536"
|
100 |
],
|
101 |
label="Resolution",
|
102 |
+
value="832x1216"
|
103 |
)
|
104 |
+
guidance_scale_input = gr.Slider(minimum=1, maximum=20, step=0.5, label="Guidance Scale", value=7)
|
105 |
+
num_inference_steps_input = gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=28)
|
106 |
+
seed_input = gr.Slider(minimum=0, maximum=999999999, step=1, label="Seed", value=0, interactive=True)
|
107 |
randomize_seed_input = gr.Checkbox(label="Randomize Seed", value=True)
|
108 |
generate_button = gr.Button("Generate Comparison")
|
109 |
reset_button = gr.Button("Reset")
|
110 |
|
111 |
with gr.Column():
|
112 |
with gr.Row():
|
113 |
+
output_image1 = gr.Image(type="pil", label="UrangDiffusion 1.4")
|
114 |
+
output_image2 = gr.Image(type="pil", label="UrangDiffusion 2.0")
|
115 |
with gr.Accordion("Parameters", open=False):
|
116 |
gr.Markdown(
|
117 |
"""
|
|
|
122 |
gr.Markdown(
|
123 |
"""
|
124 |
### Recommended prompt formatting:
|
125 |
+
`1girl/1boy, character name, from what series, everything else in any order, best quality, amazing quality, very aesthetic`
|
126 |
|
127 |
+
**PS:** `best quality, amazing quality, very aesthetic` is automatically added when "Use Default Quality Tags and Negative Prompt" is enabled
|
128 |
|
129 |
### Recommended settings:
|
130 |
- Steps: 25-30
|