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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
import numpy as np
|
5 |
+
import spaces
|
6 |
+
import torch
|
7 |
+
from pipeline.mixture_tiling_sdxl import StableDiffusionXLTilingPipeline
|
8 |
+
from pipeline.util import SAMPLERS, create_hdr_effect, select_scheduler
|
9 |
+
|
10 |
+
from diffusers import AutoencoderKL
|
11 |
+
|
12 |
+
|
13 |
+
MAX_SEED = np.iinfo(np.int32).max
|
14 |
+
|
15 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16).to("cuda")
|
16 |
+
|
17 |
+
model_id = "stablediffusionapi/yamermix-v8-vae"
|
18 |
+
pipe = StableDiffusionXLTilingPipeline.from_pretrained(
|
19 |
+
model_id,
|
20 |
+
torch_dtype=torch.float16,
|
21 |
+
vae=vae,
|
22 |
+
use_safetensors=False, # for yammermix
|
23 |
+
# variant="fp16",
|
24 |
+
).to("cuda")
|
25 |
+
|
26 |
+
#pipe.enable_model_cpu_offload() # << Enable this if you have limited VRAM
|
27 |
+
pipe.enable_vae_tiling()
|
28 |
+
pipe.enable_vae_slicing()
|
29 |
+
|
30 |
+
|
31 |
+
# region functions
|
32 |
+
@spaces.GPU
|
33 |
+
def predict(
|
34 |
+
left_prompt,
|
35 |
+
center_prompt,
|
36 |
+
right_prompt,
|
37 |
+
negative_prompt,
|
38 |
+
left_gs,
|
39 |
+
center_gs,
|
40 |
+
right_gs,
|
41 |
+
overlap_pixels,
|
42 |
+
steps,
|
43 |
+
generation_seed,
|
44 |
+
scheduler,
|
45 |
+
tile_height,
|
46 |
+
tile_width,
|
47 |
+
target_height,
|
48 |
+
target_width,
|
49 |
+
hdr,
|
50 |
+
progress=gr.Progress(track_tqdm=True),
|
51 |
+
):
|
52 |
+
global pipe
|
53 |
+
|
54 |
+
# Set selected scheduler
|
55 |
+
print(f"Using scheduler: {scheduler}...")
|
56 |
+
pipe.scheduler = select_scheduler(pipe, scheduler)
|
57 |
+
|
58 |
+
# Set seed
|
59 |
+
generator = torch.Generator("cuda").manual_seed(generation_seed)
|
60 |
+
|
61 |
+
target_height = int(target_height)
|
62 |
+
target_width = int(target_width)
|
63 |
+
tile_height = int(tile_height)
|
64 |
+
tile_width = int(tile_width)
|
65 |
+
|
66 |
+
# Mixture of Diffusers generation
|
67 |
+
image = pipe(
|
68 |
+
prompt=[
|
69 |
+
[
|
70 |
+
left_prompt,
|
71 |
+
center_prompt,
|
72 |
+
right_prompt,
|
73 |
+
]
|
74 |
+
],
|
75 |
+
negative_prompt=negative_prompt,
|
76 |
+
tile_height=tile_height,
|
77 |
+
tile_width=tile_width,
|
78 |
+
tile_row_overlap=0,
|
79 |
+
tile_col_overlap=overlap_pixels,
|
80 |
+
guidance_scale_tiles=[[left_gs, center_gs, right_gs]],
|
81 |
+
height=target_height,
|
82 |
+
width=target_width,
|
83 |
+
generator=generator,
|
84 |
+
num_inference_steps=steps,
|
85 |
+
)["images"][0]
|
86 |
+
|
87 |
+
image = create_hdr_effect(image, hdr)
|
88 |
+
return image
|
89 |
+
|
90 |
+
|
91 |
+
def calc_tile_size(target_height, target_width, overlap_pixels, max_tile_width_size=1280):
|
92 |
+
num_cols = 3
|
93 |
+
num_rows = 1
|
94 |
+
min_tile_dimension = 8
|
95 |
+
reduction_step = 8
|
96 |
+
max_tile_height_size = 1024
|
97 |
+
best_tile_width = 0
|
98 |
+
best_tile_height = 0
|
99 |
+
best_adjusted_target_width = 0
|
100 |
+
best_adjusted_target_height = 0
|
101 |
+
found_valid_solution = False
|
102 |
+
|
103 |
+
# Adjust Tile Width
|
104 |
+
tile_width = max_tile_width_size
|
105 |
+
tile_height = max_tile_height_size
|
106 |
+
|
107 |
+
while tile_width >= min_tile_dimension:
|
108 |
+
horizontal_borders = num_cols - 1
|
109 |
+
total_horizontal_overlap_pixels = overlap_pixels * horizontal_borders
|
110 |
+
adjusted_target_width = tile_width * num_cols - total_horizontal_overlap_pixels
|
111 |
+
|
112 |
+
vertical_borders = num_rows - 1
|
113 |
+
total_vertical_overlap_pixels = overlap_pixels * vertical_borders
|
114 |
+
adjusted_target_height = tile_height * num_rows - total_vertical_overlap_pixels
|
115 |
+
|
116 |
+
if tile_width <= max_tile_width_size and adjusted_target_width <= target_width:
|
117 |
+
if adjusted_target_width > best_adjusted_target_width:
|
118 |
+
best_tile_width = tile_width
|
119 |
+
best_adjusted_target_width = adjusted_target_width
|
120 |
+
found_valid_solution = True
|
121 |
+
|
122 |
+
tile_width -= reduction_step
|
123 |
+
|
124 |
+
# Adjust Tile Height
|
125 |
+
if found_valid_solution:
|
126 |
+
tile_width = best_tile_width
|
127 |
+
tile_height = max_tile_height_size
|
128 |
+
|
129 |
+
while tile_height >= min_tile_dimension:
|
130 |
+
horizontal_borders = num_cols - 1
|
131 |
+
total_horizontal_overlap_pixels = overlap_pixels * horizontal_borders
|
132 |
+
adjusted_target_width = tile_width * num_cols - total_horizontal_overlap_pixels
|
133 |
+
|
134 |
+
vertical_borders = num_rows - 1
|
135 |
+
total_vertical_overlap_pixels = overlap_pixels * vertical_borders
|
136 |
+
adjusted_target_height = tile_height * num_rows - total_vertical_overlap_pixels
|
137 |
+
|
138 |
+
if tile_height <= max_tile_height_size and adjusted_target_height <= target_height:
|
139 |
+
if adjusted_target_height > best_adjusted_target_height:
|
140 |
+
best_tile_height = tile_height
|
141 |
+
best_adjusted_target_height = adjusted_target_height
|
142 |
+
|
143 |
+
tile_height -= reduction_step
|
144 |
+
|
145 |
+
new_target_height = best_adjusted_target_height
|
146 |
+
new_target_width = best_adjusted_target_width
|
147 |
+
tile_width = best_tile_width
|
148 |
+
tile_height = best_tile_height
|
149 |
+
|
150 |
+
print("--- TILE SIZE CALCULATED VALUES ---")
|
151 |
+
print(f"Overlap pixels (requested): {overlap_pixels}")
|
152 |
+
print(f"Tile Height (divisible by 8, max {max_tile_height_size}): {tile_height}")
|
153 |
+
print(f"Tile Width (divisible by 8, max {max_tile_width_size}): {tile_width}")
|
154 |
+
print(f"Number of Columns (horizontal tiles): {num_cols}")
|
155 |
+
print(f"Number of Rows (vertical tiles): {num_rows}")
|
156 |
+
print(f"Original Target Height: {target_height}")
|
157 |
+
print(f"Original Target Width: {target_width}")
|
158 |
+
print(f"New Target Height (total covered height): {new_target_height}")
|
159 |
+
print(f"New Target Width (total covered width): {new_target_width}\n")
|
160 |
+
|
161 |
+
return new_target_height, new_target_width, tile_height, tile_width
|
162 |
+
|
163 |
+
|
164 |
+
def do_calc_tile(target_height, target_width, overlap_pixels, max_tile_size):
|
165 |
+
new_target_height, new_target_width, tile_height, tile_width = calc_tile_size(
|
166 |
+
target_height, target_width, overlap_pixels, max_tile_size
|
167 |
+
)
|
168 |
+
return (
|
169 |
+
gr.update(value=tile_height),
|
170 |
+
gr.update(value=tile_width),
|
171 |
+
gr.update(value=new_target_height),
|
172 |
+
gr.update(value=new_target_width),
|
173 |
+
)
|
174 |
+
|
175 |
+
|
176 |
+
def clear_result():
|
177 |
+
return gr.update(value=None)
|
178 |
+
|
179 |
+
|
180 |
+
def run_for_examples(
|
181 |
+
left_prompt,
|
182 |
+
center_prompt,
|
183 |
+
right_prompt,
|
184 |
+
negative_prompt,
|
185 |
+
left_gs,
|
186 |
+
center_gs,
|
187 |
+
right_gs,
|
188 |
+
overlap_pixels,
|
189 |
+
steps,
|
190 |
+
generation_seed,
|
191 |
+
scheduler,
|
192 |
+
tile_height,
|
193 |
+
tile_width,
|
194 |
+
target_height,
|
195 |
+
target_width,
|
196 |
+
max_tile_width,
|
197 |
+
hdr,
|
198 |
+
):
|
199 |
+
return predict(
|
200 |
+
left_prompt,
|
201 |
+
center_prompt,
|
202 |
+
right_prompt,
|
203 |
+
negative_prompt,
|
204 |
+
left_gs,
|
205 |
+
center_gs,
|
206 |
+
right_gs,
|
207 |
+
overlap_pixels,
|
208 |
+
steps,
|
209 |
+
generation_seed,
|
210 |
+
scheduler,
|
211 |
+
tile_height,
|
212 |
+
tile_width,
|
213 |
+
target_height,
|
214 |
+
target_width,
|
215 |
+
hdr,
|
216 |
+
)
|
217 |
+
|
218 |
+
|
219 |
+
def randomize_seed_fn(generation_seed: int, randomize_seed: bool) -> int:
|
220 |
+
if randomize_seed:
|
221 |
+
generation_seed = random.randint(0, MAX_SEED)
|
222 |
+
return generation_seed
|
223 |
+
|
224 |
+
|
225 |
+
css = """
|
226 |
+
body {
|
227 |
+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
228 |
+
margin: 0;
|
229 |
+
padding: 0;
|
230 |
+
}
|
231 |
+
.gradio-container {
|
232 |
+
border-radius: 15px;
|
233 |
+
padding: 30px 40px;
|
234 |
+
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
|
235 |
+
margin: 40px 340px;
|
236 |
+
}
|
237 |
+
.gradio-container h1 {
|
238 |
+
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
|
239 |
+
}
|
240 |
+
.fillable {
|
241 |
+
width: 100% !important;
|
242 |
+
max-width: unset !important;
|
243 |
+
}
|
244 |
+
#examples_container {
|
245 |
+
margin: auto;
|
246 |
+
width: 90%;
|
247 |
+
}
|
248 |
+
#examples_row {
|
249 |
+
justify-content: center;
|
250 |
+
}
|
251 |
+
#tips_row{
|
252 |
+
padding-left: 20px;
|
253 |
+
}
|
254 |
+
.sidebar {
|
255 |
+
border-radius: 10px;
|
256 |
+
padding: 10px;
|
257 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
|
258 |
+
}
|
259 |
+
.sidebar .toggle-button {
|
260 |
+
background: linear-gradient(90deg, #fbbf24, #fcd34d) !important;
|
261 |
+
border: none;
|
262 |
+
padding: 12px 24px;
|
263 |
+
text-transform: uppercase;
|
264 |
+
font-weight: bold;
|
265 |
+
letter-spacing: 1px;
|
266 |
+
border-radius: 5px;
|
267 |
+
cursor: pointer;
|
268 |
+
transition: transform 0.2s ease-in-out;
|
269 |
+
}
|
270 |
+
.toggle-button:hover {
|
271 |
+
transform: scale(1.05);
|
272 |
+
}
|
273 |
+
"""
|
274 |
+
title = """<h1 align="center">Mixture-of-Diffusers for SDXL Tiling Pipeline🤗</h1>
|
275 |
+
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; overflow:hidden;">
|
276 |
+
<span>This <a href="https://github.com/DEVAIEXP/mixture-of-diffusers-sdxl-tiling">project</a> implements a SDXL tiling pipeline based on the original project: <a href='https://github.com/albarji/mixture-of-diffusers'>Mixture-of-Diffusers</a>. For more information, see the:
|
277 |
+
<a href="https://arxiv.org/pdf/2302.02412">📜 paper </a>
|
278 |
+
</div>
|
279 |
+
"""
|
280 |
+
|
281 |
+
tips = """
|
282 |
+
### Method
|
283 |
+
The method proposed here strives to provide a better tool for image composition by using several diffusion processes in parallel, each configured with a specific prompt and settings, and focused on a particular region of the image. The mixture of diffusion processes is done in a way that harmonizes the generation process, preventing "seam" effects in the generated image.
|
284 |
+
Using several diffusion processes in parallel has also practical advantages when generating very large images, as the GPU memory requirements are similar to that of generating an image of the size of a single tile.
|
285 |
+
For practical demonstration purposes, this demo only covers image generation using 1x3 tiles. However, in the pipeline, you can freely increase the number of rows and columns as well as specify a row overlap.
|
286 |
+
|
287 |
+
### Tips
|
288 |
+
1. Describe the same environment for all image elements in your prompt. This helps to better harmonize the final image.
|
289 |
+
2. Keep the same stylization in both prompts.
|
290 |
+
3. Test different overlap sizes.
|
291 |
+
4. Test fews increments on seed.
|
292 |
+
5. This may take a while.
|
293 |
+
6. Enjoy!
|
294 |
+
"""
|
295 |
+
|
296 |
+
about = """
|
297 |
+
📧 **Contact**
|
298 |
+
<br>
|
299 |
+
If you have any questions or suggestions, feel free to send your question to <b>[email protected]</b>.
|
300 |
+
"""
|
301 |
+
|
302 |
+
with gr.Blocks(css=css, theme=gr.themes.Citrus()) as app:
|
303 |
+
gr.Markdown(title)
|
304 |
+
with gr.Row():
|
305 |
+
with gr.Column(scale=7):
|
306 |
+
generate_button = gr.Button("Generate")
|
307 |
+
with gr.Row():
|
308 |
+
with gr.Column(scale=1):
|
309 |
+
gr.Markdown("### Left region")
|
310 |
+
left_prompt = gr.Textbox(lines=4, label="Prompt for left side of the image")
|
311 |
+
left_gs = gr.Slider(minimum=0, maximum=15, value=7, step=1, label="Left CFG scale")
|
312 |
+
with gr.Column(scale=1):
|
313 |
+
gr.Markdown("### Center region")
|
314 |
+
center_prompt = gr.Textbox(lines=4, label="Prompt for the center of the image")
|
315 |
+
center_gs = gr.Slider(minimum=0, maximum=15, value=7, step=1, label="Center CFG scale")
|
316 |
+
with gr.Column(scale=1):
|
317 |
+
gr.Markdown("### Right region")
|
318 |
+
right_prompt = gr.Textbox(lines=4, label="Prompt for the right side of the image")
|
319 |
+
right_gs = gr.Slider(minimum=0, maximum=15, value=7, step=1, label="Right CFG scale")
|
320 |
+
with gr.Row():
|
321 |
+
negative_prompt = gr.Textbox(
|
322 |
+
lines=2,
|
323 |
+
label="Negative prompt for the image",
|
324 |
+
value="nsfw, lowres, bad anatomy, bad hands, duplicate, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, blurry",
|
325 |
+
)
|
326 |
+
with gr.Row():
|
327 |
+
result = gr.Image(
|
328 |
+
label="Generated Image",
|
329 |
+
show_label=True,
|
330 |
+
format="png",
|
331 |
+
interactive=False,
|
332 |
+
# allow_preview=True,
|
333 |
+
# preview=True,
|
334 |
+
scale=1,
|
335 |
+
)
|
336 |
+
with gr.Column():
|
337 |
+
gr.Markdown(tips)
|
338 |
+
with gr.Sidebar(label="Parameters", open=True):
|
339 |
+
gr.Markdown("### General parameters")
|
340 |
+
with gr.Row():
|
341 |
+
height = gr.Slider(label="Height", value=1024, step=8, visible=True, minimum=512, maximum=1024)
|
342 |
+
width = gr.Slider(label="Width", value=1280, step=8, visible=True, minimum=512, maximum=3840)
|
343 |
+
overlap = gr.Slider(minimum=0, maximum=512, value=128, step=8, label="Tile Overlap")
|
344 |
+
max_tile_size = gr.Dropdown(label="Max. Tile Size", choices=[1024, 1280], value=1280)
|
345 |
+
calc_tile = gr.Button("Calculate Tile Size")
|
346 |
+
with gr.Row():
|
347 |
+
tile_height = gr.Textbox(label="Tile height", value=1024, interactive=False)
|
348 |
+
tile_width = gr.Textbox(label="Tile width", value=1024, interactive=False)
|
349 |
+
with gr.Row():
|
350 |
+
new_target_height = gr.Textbox(label="New image height", value=1024, interactive=False)
|
351 |
+
new_target_width = gr.Textbox(label="New image width", value=1024, interactive=False)
|
352 |
+
with gr.Row():
|
353 |
+
steps = gr.Slider(minimum=1, maximum=50, value=30, step=1, label="Inference steps")
|
354 |
+
|
355 |
+
generation_seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
|
356 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=False)
|
357 |
+
with gr.Row():
|
358 |
+
hdr = gr.Slider(minimum=0, maximum=1, value=0, step=0.1, label="HDR Effect")
|
359 |
+
scheduler = gr.Dropdown(
|
360 |
+
label="Sampler",
|
361 |
+
choices=list(SAMPLERS.keys()),
|
362 |
+
value="UniPC",
|
363 |
+
)
|
364 |
+
with gr.Row():
|
365 |
+
gr.Examples(
|
366 |
+
examples=[
|
367 |
+
[
|
368 |
+
"Iron Man, repulsor rays blasting enemies in destroyed cityscape, sparks, energy trails, crumbling skyscrapers, smoke, debris, cinematic lighting, photorealistic, intense action. Focus: Iron Man.",
|
369 |
+
"Captain America charging forward, vibranium shield deflecting energy blasts in destroyed cityscape, collapsing buildings, rubble streets, battle-damaged suit, determined expression, distant explosions, cinematic composition, realistic rendering. Focus: Captain America.",
|
370 |
+
"Thor wielding Stormbreaker in destroyed cityscape, lightning crackling, powerful strike downwards, shattered buildings, burning debris, ground trembling, Asgardian armor, cinematic photography, realistic details. Focus: Thor.",
|
371 |
+
negative_prompt.value,
|
372 |
+
5,
|
373 |
+
5,
|
374 |
+
5,
|
375 |
+
160,
|
376 |
+
30,
|
377 |
+
619517442,
|
378 |
+
"UniPC",
|
379 |
+
1024,
|
380 |
+
1280,
|
381 |
+
1024,
|
382 |
+
3840,
|
383 |
+
1024,
|
384 |
+
0,
|
385 |
+
],
|
386 |
+
[
|
387 |
+
"A charming house in the countryside, by jakub rozalski, sunset lighting, elegant, highly detailed, smooth, sharp focus, artstation, stunning masterpiece",
|
388 |
+
"A dirt road in the countryside crossing pastures, by jakub rozalski, sunset lighting, elegant, highly detailed, smooth, sharp focus, artstation, stunning masterpiece",
|
389 |
+
"An old and rusty giant robot lying on a dirt road, by jakub rozalski, dark sunset lighting, elegant, highly detailed, smooth, sharp focus, artstation, stunning masterpiece",
|
390 |
+
negative_prompt.value,
|
391 |
+
7,
|
392 |
+
7,
|
393 |
+
7,
|
394 |
+
256,
|
395 |
+
30,
|
396 |
+
358867853,
|
397 |
+
"DPM++ 3M Karras",
|
398 |
+
1024,
|
399 |
+
1280,
|
400 |
+
1024,
|
401 |
+
3840,
|
402 |
+
1280,
|
403 |
+
0,
|
404 |
+
],
|
405 |
+
[
|
406 |
+
"Abstract decorative illustration, by joan miro and gustav klimt and marlina vera and loish, elegant, intricate, highly detailed, smooth, sharp focus, vibrant colors, artstation, stunning masterpiece",
|
407 |
+
"Abstract decorative illustration, by joan miro and gustav klimt and marlina vera and loish, elegant, intricate, highly detailed, smooth, sharp focus, vibrant colors, artstation, stunning masterpiece",
|
408 |
+
"Abstract decorative illustration, by joan miro and gustav klimt and marlina vera and loish, elegant, intricate, highly detailed, smooth, sharp focus, vibrant colors, artstation, stunning masterpiece",
|
409 |
+
negative_prompt.value,
|
410 |
+
7,
|
411 |
+
7,
|
412 |
+
7,
|
413 |
+
128,
|
414 |
+
30,
|
415 |
+
580541206,
|
416 |
+
"LMS",
|
417 |
+
1024,
|
418 |
+
768,
|
419 |
+
1024,
|
420 |
+
2048,
|
421 |
+
1280,
|
422 |
+
0,
|
423 |
+
],
|
424 |
+
[
|
425 |
+
"Magical diagrams and runes written with chalk on a blackboard, elegant, intricate, highly detailed, smooth, sharp focus, artstation, stunning masterpiece",
|
426 |
+
"Magical diagrams and runes written with chalk on a blackboard, elegant, intricate, highly detailed, smooth, sharp focus, artstation, stunning masterpiece",
|
427 |
+
"Magical diagrams and runes written with chalk on a blackboard, elegant, intricate, highly detailed, smooth, sharp focus, artstation, stunning masterpiece",
|
428 |
+
negative_prompt.value,
|
429 |
+
9,
|
430 |
+
9,
|
431 |
+
9,
|
432 |
+
128,
|
433 |
+
30,
|
434 |
+
12591765619,
|
435 |
+
"LMS",
|
436 |
+
1024,
|
437 |
+
768,
|
438 |
+
1024,
|
439 |
+
2048,
|
440 |
+
1280,
|
441 |
+
0,
|
442 |
+
],
|
443 |
+
],
|
444 |
+
inputs=[
|
445 |
+
left_prompt,
|
446 |
+
center_prompt,
|
447 |
+
right_prompt,
|
448 |
+
negative_prompt,
|
449 |
+
left_gs,
|
450 |
+
center_gs,
|
451 |
+
right_gs,
|
452 |
+
overlap,
|
453 |
+
steps,
|
454 |
+
generation_seed,
|
455 |
+
scheduler,
|
456 |
+
tile_height,
|
457 |
+
tile_width,
|
458 |
+
height,
|
459 |
+
width,
|
460 |
+
max_tile_size,
|
461 |
+
hdr,
|
462 |
+
],
|
463 |
+
fn=run_for_examples,
|
464 |
+
outputs=result,
|
465 |
+
cache_examples=True,
|
466 |
+
)
|
467 |
+
|
468 |
+
event_calc_tile_size = {
|
469 |
+
"fn": do_calc_tile,
|
470 |
+
"inputs": [height, width, overlap, max_tile_size],
|
471 |
+
"outputs": [tile_height, tile_width, new_target_height, new_target_width],
|
472 |
+
}
|
473 |
+
calc_tile.click(**event_calc_tile_size)
|
474 |
+
|
475 |
+
generate_button.click(
|
476 |
+
fn=clear_result,
|
477 |
+
inputs=None,
|
478 |
+
outputs=result,
|
479 |
+
).then(**event_calc_tile_size).then(
|
480 |
+
fn=randomize_seed_fn,
|
481 |
+
inputs=[generation_seed, randomize_seed],
|
482 |
+
outputs=generation_seed,
|
483 |
+
queue=False,
|
484 |
+
api_name=False,
|
485 |
+
).then(
|
486 |
+
fn=predict,
|
487 |
+
inputs=[
|
488 |
+
left_prompt,
|
489 |
+
center_prompt,
|
490 |
+
right_prompt,
|
491 |
+
negative_prompt,
|
492 |
+
left_gs,
|
493 |
+
center_gs,
|
494 |
+
right_gs,
|
495 |
+
overlap,
|
496 |
+
steps,
|
497 |
+
generation_seed,
|
498 |
+
scheduler,
|
499 |
+
tile_height,
|
500 |
+
tile_width,
|
501 |
+
new_target_height,
|
502 |
+
new_target_width,
|
503 |
+
hdr,
|
504 |
+
],
|
505 |
+
outputs=result,
|
506 |
+
)
|
507 |
+
gr.Markdown(about)
|
508 |
+
app.launch(share=False)
|