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 = {