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
  # ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ: ํƒ€์ผ ์‚ฌ์ด์ฆˆ ๊ณ„์‚ฐ ๋ฐ ์ด๋ฏธ์ง€ ์ƒ์„ฑ