Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ SCHEDULERS = [
|
|
19 |
"UniPCMultistepScheduler"
|
20 |
]
|
21 |
|
22 |
-
# ๋ก๋ฉ: VAE ๋ฐ ํ์ผ๋ง ํ์ดํ๋ผ์ธ
|
23 |
vae = AutoencoderKL.from_pretrained(
|
24 |
"madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16
|
25 |
).to("cuda")
|
@@ -59,7 +59,7 @@ def select_scheduler(scheduler_name):
|
|
59 |
def predict(left_prompt, center_prompt, right_prompt, negative_prompt, left_gs, center_gs, right_gs,
|
60 |
overlap_pixels, steps, generation_seed, scheduler, tile_height, tile_width, target_height, target_width):
|
61 |
global pipe
|
62 |
-
# ์ค์ผ์ค๋ฌ
|
63 |
print(f"Using scheduler: {scheduler}...")
|
64 |
pipe.scheduler = select_scheduler(scheduler)
|
65 |
|
@@ -71,7 +71,7 @@ def predict(left_prompt, center_prompt, right_prompt, negative_prompt, left_gs,
|
|
71 |
tile_height = int(tile_height)
|
72 |
tile_width = int(tile_width)
|
73 |
|
74 |
-
#
|
75 |
image = pipe(
|
76 |
prompt=[[left_prompt, center_prompt, right_prompt]],
|
77 |
negative_prompt=negative_prompt,
|
@@ -160,18 +160,13 @@ def do_calc_tile(target_height, target_width, overlap_pixels, max_tile_size):
|
|
160 |
def clear_result():
|
161 |
return gr.update(value=None)
|
162 |
|
163 |
-
def run_for_examples(left_prompt, center_prompt, right_prompt, negative_prompt, left_gs, center_gs, right_gs,
|
164 |
-
overlap_pixels, steps, generation_seed, scheduler, tile_height, tile_width, target_height, target_width, max_tile_width):
|
165 |
-
return predict(left_prompt, center_prompt, right_prompt, negative_prompt, left_gs, center_gs, right_gs,
|
166 |
-
overlap_pixels, steps, generation_seed, scheduler, tile_height, tile_width, target_height, target_width)
|
167 |
-
|
168 |
def randomize_seed_fn(generation_seed: int, randomize_seed: bool) -> int:
|
169 |
if randomize_seed:
|
170 |
generation_seed = random.randint(0, MAX_SEED)
|
171 |
return generation_seed
|
172 |
#endregion
|
173 |
|
174 |
-
# ๊ฐ์ ๋ CSS: ๋ฐฐ๊ฒฝ์, ์ฌ๋ฐฑ, ๊ทธ๋ฆผ์
|
175 |
css = """
|
176 |
body { background-color: #f0f2f5; }
|
177 |
.gradio-container {
|
@@ -182,14 +177,21 @@ body { background-color: #f0f2f5; }
|
|
182 |
}
|
183 |
.gradio-container h1 { color: #333333; }
|
184 |
.fillable { width: 95% !important; max-width: unset !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
"""
|
186 |
|
187 |
# ์ ๋ชฉ ๋ฐ ๊ฐ๋จํ ์ค๋ช
|
188 |
title = """
|
189 |
<h1 align="center" style="margin-bottom: 0.2em;">Mixture-of-Diffusers for SDXL Tiling Pipeline ๐ค</h1>
|
190 |
<p align="center" style="font-size:1.1em; color:#555;">
|
191 |
-
์ข/์ค์/์ฐ
|
192 |
-
|
193 |
</p>
|
194 |
"""
|
195 |
|
@@ -245,79 +247,79 @@ with gr.Blocks(css=css, title="SDXL Tiling Pipeline") as app:
|
|
245 |
with gr.Row():
|
246 |
scheduler = gr.Dropdown(label="Scheduler", choices=SCHEDULERS, value=SCHEDULERS[0])
|
247 |
|
248 |
-
#
|
249 |
-
with gr.Row():
|
250 |
-
gr.
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
],
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
9, 9, 9,
|
305 |
-
150,
|
306 |
-
40,
|
307 |
-
1029384756,
|
308 |
-
"DPMSolverMultistepScheduler-Karras-SDE",
|
309 |
-
1024, 1280,
|
310 |
-
1024, 1920,
|
311 |
-
1280
|
312 |
-
]
|
313 |
-
],
|
314 |
-
inputs=[left_prompt, center_prompt, right_prompt, negative_prompt,
|
315 |
-
left_gs, center_gs, right_gs, overlap, steps, generation_seed,
|
316 |
-
scheduler, tile_height, tile_width, height, width, max_tile_size],
|
317 |
-
fn=run_for_examples,
|
318 |
-
outputs=result,
|
319 |
-
cache_examples=True
|
320 |
-
)
|
321 |
|
322 |
# ์ด๋ฒคํธ ์ฐ๊ฒฐ: ํ์ผ ์ฌ์ด์ฆ ๊ณ์ฐ ๋ฐ ์ด๋ฏธ์ง ์์ฑ
|
323 |
event_calc_tile_size = {
|
|
|
19 |
"UniPCMultistepScheduler"
|
20 |
]
|
21 |
|
22 |
+
# ๋ชจ๋ธ ๋ก๋ฉ: VAE ๋ฐ ํ์ผ๋ง ํ์ดํ๋ผ์ธ ์ด๊ธฐํ
|
23 |
vae = AutoencoderKL.from_pretrained(
|
24 |
"madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16
|
25 |
).to("cuda")
|
|
|
59 |
def predict(left_prompt, center_prompt, right_prompt, negative_prompt, left_gs, center_gs, right_gs,
|
60 |
overlap_pixels, steps, generation_seed, scheduler, tile_height, tile_width, target_height, target_width):
|
61 |
global pipe
|
62 |
+
# ์ค์ผ์ค๋ฌ ์ค์
|
63 |
print(f"Using scheduler: {scheduler}...")
|
64 |
pipe.scheduler = select_scheduler(scheduler)
|
65 |
|
|
|
71 |
tile_height = int(tile_height)
|
72 |
tile_width = int(tile_width)
|
73 |
|
74 |
+
# ์ข/์ค์/์ฐ ์์ญ ํ๋กฌํํธ๋ฅผ ์ด์ฉํ ํ์ผ๋ง ์ด๋ฏธ์ง ์์ฑ
|
75 |
image = pipe(
|
76 |
prompt=[[left_prompt, center_prompt, right_prompt]],
|
77 |
negative_prompt=negative_prompt,
|
|
|
160 |
def clear_result():
|
161 |
return gr.update(value=None)
|
162 |
|
|
|
|
|
|
|
|
|
|
|
163 |
def randomize_seed_fn(generation_seed: int, randomize_seed: bool) -> int:
|
164 |
if randomize_seed:
|
165 |
generation_seed = random.randint(0, MAX_SEED)
|
166 |
return generation_seed
|
167 |
#endregion
|
168 |
|
169 |
+
# ๊ฐ์ ๋ CSS: ๋ฐฐ๊ฒฝ์, ์ฌ๋ฐฑ, ๊ทธ๋ฆผ์ ๋ฐ ์ค์ ์ ๋ ฌ ์ถ๊ฐ
|
170 |
css = """
|
171 |
body { background-color: #f0f2f5; }
|
172 |
.gradio-container {
|
|
|
177 |
}
|
178 |
.gradio-container h1 { color: #333333; }
|
179 |
.fillable { width: 95% !important; max-width: unset !important; }
|
180 |
+
#examples_container {
|
181 |
+
margin: auto;
|
182 |
+
width: 90%;
|
183 |
+
}
|
184 |
+
#examples_row {
|
185 |
+
justify-content: center;
|
186 |
+
}
|
187 |
"""
|
188 |
|
189 |
# ์ ๋ชฉ ๋ฐ ๊ฐ๋จํ ์ค๋ช
|
190 |
title = """
|
191 |
<h1 align="center" style="margin-bottom: 0.2em;">Mixture-of-Diffusers for SDXL Tiling Pipeline ๐ค</h1>
|
192 |
<p align="center" style="font-size:1.1em; color:#555;">
|
193 |
+
์ข/์ค์/์ฐ ๊ฐ ์์ญ์ ๋ค๋ฅธ ํ๋กฌํํธ๋ฅผ ์ ์ฉํ์ฌ ํ์ผ๋ง ์ด๋ฏธ์ง๋ฅผ ์์ฑํฉ๋๋ค.<br>
|
194 |
+
์๋ ์์ ๋ฅผ ํด๋ฆญํ๋ฉด ์
๋ ฅ์ฐฝ์ ๊ฐ์ด ์ฑ์์ง๋๋ค.
|
195 |
</p>
|
196 |
"""
|
197 |
|
|
|
247 |
with gr.Row():
|
248 |
scheduler = gr.Dropdown(label="Scheduler", choices=SCHEDULERS, value=SCHEDULERS[0])
|
249 |
|
250 |
+
# ์ค์์ ๋ฐฐ์น๋ ์์ ์์ญ
|
251 |
+
with gr.Row(elem_id="examples_row"):
|
252 |
+
with gr.Column(scale=12, elem_id="examples_container"):
|
253 |
+
gr.Markdown("### Example Prompts")
|
254 |
+
gr.Examples(
|
255 |
+
examples=[
|
256 |
+
# Example 1: Serene Nature
|
257 |
+
[
|
258 |
+
"Lush green forest with sun rays filtering through the canopy",
|
259 |
+
"Crystal clear lake reflecting a vibrant sky",
|
260 |
+
"Majestic mountains with snowy peaks in the distance",
|
261 |
+
"blurry, low resolution, artifacts, poor details",
|
262 |
+
7, 7, 7,
|
263 |
+
128,
|
264 |
+
30,
|
265 |
+
123456789,
|
266 |
+
"UniPCMultistepScheduler",
|
267 |
+
1024, 1280,
|
268 |
+
1024, 1920,
|
269 |
+
1280
|
270 |
+
],
|
271 |
+
# Example 2: Futuristic Cityscape
|
272 |
+
[
|
273 |
+
"Vibrant city street with neon signs and bustling crowds",
|
274 |
+
"Sleek modern skyscrapers with digital billboards",
|
275 |
+
"High-speed maglev train gliding over a futuristic urban landscape",
|
276 |
+
"blurry, poorly rendered, low quality, disfigured",
|
277 |
+
8, 8, 8,
|
278 |
+
100,
|
279 |
+
35,
|
280 |
+
987654321,
|
281 |
+
"EulerDiscreteScheduler",
|
282 |
+
1024, 1280,
|
283 |
+
1024, 1920,
|
284 |
+
1280
|
285 |
+
],
|
286 |
+
# Example 3: Abstract Art
|
287 |
+
[
|
288 |
+
"Vibrant abstract strokes with fluid, swirling patterns in cool tones",
|
289 |
+
"Interlocking geometric shapes bursting with color and texture",
|
290 |
+
"Dynamic composition of splattered ink with smooth gradients",
|
291 |
+
"text, watermark, signature, distorted",
|
292 |
+
6, 6, 6,
|
293 |
+
80,
|
294 |
+
25,
|
295 |
+
192837465,
|
296 |
+
"DPMSolverMultistepScheduler-Karras",
|
297 |
+
1024, 1280,
|
298 |
+
1024, 1920,
|
299 |
+
1280
|
300 |
+
],
|
301 |
+
# Example 4: Fantasy Landscape
|
302 |
+
[
|
303 |
+
"Enchanted forest with glowing bioluminescent plants and mystical fog",
|
304 |
+
"Ancient castle with towering spires bathed in moonlight",
|
305 |
+
"Majestic dragon soaring above a starry night sky",
|
306 |
+
"low quality, artifact, deformed, sketchy",
|
307 |
+
9, 9, 9,
|
308 |
+
150,
|
309 |
+
40,
|
310 |
+
1029384756,
|
311 |
+
"DPMSolverMultistepScheduler-Karras-SDE",
|
312 |
+
1024, 1280,
|
313 |
+
1024, 1920,
|
314 |
+
1280
|
315 |
+
]
|
316 |
],
|
317 |
+
inputs=[left_prompt, center_prompt, right_prompt, negative_prompt,
|
318 |
+
left_gs, center_gs, right_gs, overlap, steps, generation_seed,
|
319 |
+
scheduler, tile_height, tile_width, height, width, max_tile_size],
|
320 |
+
cache_examples=True
|
321 |
+
# fn์ outputs ์ธ์๋ฅผ ์ ๊ฑฐํ์ฌ ์์ ํด๋ฆญ์ ์
๋ ฅ์ฐฝ์ ๊ฐ์ด ์ฑ์์ง๋๋ก ํจ.
|
322 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
|
324 |
# ์ด๋ฒคํธ ์ฐ๊ฒฐ: ํ์ผ ์ฌ์ด์ฆ ๊ณ์ฐ ๋ฐ ์ด๋ฏธ์ง ์์ฑ
|
325 |
event_calc_tile_size = {
|