fantos commited on
Commit
d8fc7c0
Β·
verified Β·
1 Parent(s): 78ba3f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -20
app.py CHANGED
@@ -59,11 +59,8 @@ 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
-
66
- # μ‹œλ“œ μ„€μ •
67
  generator = torch.Generator("cuda").manual_seed(generation_seed)
68
 
69
  target_height = int(target_height)
@@ -71,7 +68,6 @@ 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,
@@ -85,7 +81,6 @@ def predict(left_prompt, center_prompt, right_prompt, negative_prompt, left_gs,
85
  generator=generator,
86
  num_inference_steps=steps,
87
  )["images"][0]
88
-
89
  return image
90
 
91
  def calc_tile_size(target_height, target_width, overlap_pixels, max_tile_width_size=1280):
@@ -100,7 +95,6 @@ def calc_tile_size(target_height, target_width, overlap_pixels, max_tile_width_s
100
  best_adjusted_target_height = 0
101
  found_valid_solution = False
102
 
103
- # 타일 λ„ˆλΉ„ κ²°μ •
104
  tile_width = max_tile_width_size
105
  tile_height = max_tile_height_size
106
  while tile_width >= min_tile_dimension:
@@ -119,7 +113,6 @@ def calc_tile_size(target_height, target_width, overlap_pixels, max_tile_width_s
119
  found_valid_solution = True
120
  tile_width -= reduction_step
121
 
122
- # 타일 높이 κ²°μ •
123
  if found_valid_solution:
124
  tile_width = best_tile_width
125
  tile_height = max_tile_height_size
@@ -166,7 +159,7 @@ def randomize_seed_fn(generation_seed: int, randomize_seed: bool) -> int:
166
  return generation_seed
167
  #endregion
168
 
169
- # κ°œμ„ λœ CSS: 배경색, μ—¬λ°±, 그림자 및 쀑앙 μ •λ ¬ μΆ”κ°€
170
  css = """
171
  body { background-color: #f0f2f5; }
172
  .gradio-container {
@@ -186,7 +179,6 @@ body { background-color: #f0f2f5; }
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;">
@@ -199,7 +191,7 @@ with gr.Blocks(css=css, title="SDXL Tiling Pipeline") as app:
199
  gr.Markdown(title)
200
 
201
  with gr.Row():
202
- # 쒌/쀑앙/우 μ˜μ—­ ν”„λ‘¬ν”„νŠΈ 및 κ²°κ³Ό 좜λ ₯ μ˜μ—­
203
  with gr.Column(scale=7):
204
  generate_button = gr.Button("Generate", elem_id="generate_btn")
205
  with gr.Row():
@@ -225,7 +217,7 @@ with gr.Blocks(css=css, title="SDXL Tiling Pipeline") as app:
225
  with gr.Row():
226
  result = gr.Image(label="Generated Image", show_label=True, format="png", interactive=False, scale=1)
227
 
228
- # 우츑 μ‚¬μ΄λ“œλ°”: νŒŒλΌλ―Έν„° 및 타일 크기 계산
229
  with gr.Sidebar(label="Parameters", open=True):
230
  gr.Markdown("### Generation Parameters")
231
  with gr.Row():
@@ -253,7 +245,6 @@ with gr.Blocks(css=css, title="SDXL Tiling Pipeline") as app:
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",
@@ -268,7 +259,6 @@ with gr.Blocks(css=css, title="SDXL Tiling Pipeline") as app:
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",
@@ -283,7 +273,6 @@ with gr.Blocks(css=css, title="SDXL Tiling Pipeline") as app:
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",
@@ -298,7 +287,6 @@ with gr.Blocks(css=css, title="SDXL Tiling Pipeline") as app:
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",
@@ -314,11 +302,7 @@ with gr.Blocks(css=css, title="SDXL Tiling Pipeline") as app:
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
  # 이벀트 μ—°κ²°: 타일 μ‚¬μ΄μ¦ˆ 계산 및 이미지 생성
 
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
  print(f"Using scheduler: {scheduler}...")
63
  pipe.scheduler = select_scheduler(scheduler)
 
 
64
  generator = torch.Generator("cuda").manual_seed(generation_seed)
65
 
66
  target_height = int(target_height)
 
68
  tile_height = int(tile_height)
69
  tile_width = int(tile_width)
70
 
 
71
  image = pipe(
72
  prompt=[[left_prompt, center_prompt, right_prompt]],
73
  negative_prompt=negative_prompt,
 
81
  generator=generator,
82
  num_inference_steps=steps,
83
  )["images"][0]
 
84
  return image
85
 
86
  def calc_tile_size(target_height, target_width, overlap_pixels, max_tile_width_size=1280):
 
95
  best_adjusted_target_height = 0
96
  found_valid_solution = False
97
 
 
98
  tile_width = max_tile_width_size
99
  tile_height = max_tile_height_size
100
  while tile_width >= min_tile_dimension:
 
113
  found_valid_solution = True
114
  tile_width -= reduction_step
115
 
 
116
  if found_valid_solution:
117
  tile_width = best_tile_width
118
  tile_height = max_tile_height_size
 
159
  return generation_seed
160
  #endregion
161
 
162
+ # CSS κ°œμ„ : λ°°κ²½, μ—¬λ°±, 그림자 및 예제 μ˜μ—­ 쀑앙 배치
163
  css = """
164
  body { background-color: #f0f2f5; }
165
  .gradio-container {
 
179
  }
180
  """
181
 
 
182
  title = """
183
  <h1 align="center" style="margin-bottom: 0.2em;">Mixture-of-Diffusers for SDXL Tiling Pipeline πŸ€—</h1>
184
  <p align="center" style="font-size:1.1em; color:#555;">
 
191
  gr.Markdown(title)
192
 
193
  with gr.Row():
194
+ # 쒌/쀑앙/우 ν”„λ‘¬ν”„νŠΈ 및 κ²°κ³Ό μ˜μ—­
195
  with gr.Column(scale=7):
196
  generate_button = gr.Button("Generate", elem_id="generate_btn")
197
  with gr.Row():
 
217
  with gr.Row():
218
  result = gr.Image(label="Generated Image", show_label=True, format="png", interactive=False, scale=1)
219
 
220
+ # μ‚¬μ΄λ“œλ°”: νŒŒλΌλ―Έν„° 및 타일 크기 계산
221
  with gr.Sidebar(label="Parameters", open=True):
222
  gr.Markdown("### Generation Parameters")
223
  with gr.Row():
 
245
  gr.Markdown("### Example Prompts")
246
  gr.Examples(
247
  examples=[
 
248
  [
249
  "Lush green forest with sun rays filtering through the canopy",
250
  "Crystal clear lake reflecting a vibrant sky",
 
259
  1024, 1920,
260
  1280
261
  ],
 
262
  [
263
  "Vibrant city street with neon signs and bustling crowds",
264
  "Sleek modern skyscrapers with digital billboards",
 
273
  1024, 1920,
274
  1280
275
  ],
 
276
  [
277
  "Vibrant abstract strokes with fluid, swirling patterns in cool tones",
278
  "Interlocking geometric shapes bursting with color and texture",
 
287
  1024, 1920,
288
  1280
289
  ],
 
290
  [
291
  "Enchanted forest with glowing bioluminescent plants and mystical fog",
292
  "Ancient castle with towering spires bathed in moonlight",
 
302
  1280
303
  ]
304
  ],
305
+ cache_examples=False
 
 
 
 
306
  )
307
 
308
  # 이벀트 μ—°κ²°: 타일 μ‚¬μ΄μ¦ˆ 계산 및 이미지 생성