fantos commited on
Commit
78ba3f1
ยท
verified ยท
1 Parent(s): 6891a4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +85 -83
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: ๋ฐฐ๊ฒฝ์ƒ‰, ์—ฌ๋ฐฑ, ๊ทธ๋ฆผ์ž ๋“ฑ์„ ์ถ”๊ฐ€ํ•˜์—ฌ UI๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ํ‘œํ˜„
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
- ์ขŒ/์ค‘์•™/์šฐ ์„ธ ์˜์—ญ ๊ฐ๊ฐ์— ๋‹ค๋ฅธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ ์šฉํ•˜์—ฌ ํƒ€์ผ๋ง ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.<br>
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.Markdown("### Example Prompts")
251
- gr.Examples(
252
- examples=[
253
- # Example 1: Serene Nature
254
- [
255
- "Lush green forest with sun rays filtering through the canopy",
256
- "Crystal clear lake reflecting a vibrant sky",
257
- "Majestic mountains with snowy peaks in the distance",
258
- "blurry, low resolution, artifacts, poor details",
259
- 7, 7, 7,
260
- 128,
261
- 30,
262
- 123456789,
263
- "UniPCMultistepScheduler",
264
- 1024, 1280,
265
- 1024, 1920,
266
- 1280
267
- ],
268
- # Example 2: Futuristic Cityscape
269
- [
270
- "Vibrant city street with neon signs and bustling crowds",
271
- "Sleek modern skyscrapers with digital billboards",
272
- "High-speed maglev train gliding over a futuristic urban landscape",
273
- "blurry, poorly rendered, low quality, disfigured",
274
- 8, 8, 8,
275
- 100,
276
- 35,
277
- 987654321,
278
- "EulerDiscreteScheduler",
279
- 1024, 1280,
280
- 1024, 1920,
281
- 1280
282
- ],
283
- # Example 3: Abstract Art
284
- [
285
- "Vibrant abstract strokes with fluid, swirling patterns in cool tones",
286
- "Interlocking geometric shapes bursting with color and texture",
287
- "Dynamic composition of splattered ink with smooth gradients",
288
- "text, watermark, signature, distorted",
289
- 6, 6, 6,
290
- 80,
291
- 25,
292
- 192837465,
293
- "DPMSolverMultistepScheduler-Karras",
294
- 1024, 1280,
295
- 1024, 1920,
296
- 1280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  ],
298
- # Example 4: Fantasy Landscape
299
- [
300
- "Enchanted forest with glowing bioluminescent plants and mystical fog",
301
- "Ancient castle with towering spires bathed in moonlight",
302
- "Majestic dragon soaring above a starry night sky",
303
- "low quality, artifact, deformed, sketchy",
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 = {