Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -269,20 +269,31 @@ def generate_grid(prompt, selected_models, custom_lora, negative_prompt, steps,
|
|
269 |
if len(selected_models) == 0:
|
270 |
raise gr.Error("Please select at least 1 model")
|
271 |
|
272 |
-
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
try:
|
275 |
img = query(prompt, model_name, custom_lora, negative_prompt, steps, cfg_scale, seed, strength, width, height)
|
276 |
-
images
|
|
|
|
|
277 |
except Exception as e:
|
278 |
print(f"Error generating image for {model_name}: {str(e)}")
|
279 |
continue
|
280 |
|
281 |
-
#
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
284 |
|
285 |
-
|
286 |
|
287 |
css = """
|
288 |
footer {
|
@@ -398,7 +409,8 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as dalle:
|
|
398 |
height="auto"
|
399 |
)
|
400 |
|
401 |
-
|
|
|
402 |
generate_btn.click(
|
403 |
fn=generate_grid,
|
404 |
inputs=[
|
@@ -413,9 +425,11 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as dalle:
|
|
413 |
width,
|
414 |
height
|
415 |
],
|
416 |
-
outputs=gallery
|
|
|
417 |
)
|
418 |
|
|
|
419 |
def filter_models(search_term):
|
420 |
filtered_models = [m for m in models_list if search_term.lower() in m.lower()]
|
421 |
return gr.update(choices=filtered_models, value=[])
|
|
|
269 |
if len(selected_models) == 0:
|
270 |
raise gr.Error("Please select at least 1 model")
|
271 |
|
272 |
+
# 초기 이미지 배열 생성 (None으로 채움)
|
273 |
+
images = [None] * 4
|
274 |
+
|
275 |
+
def update_gallery():
|
276 |
+
return images
|
277 |
+
|
278 |
+
# 각 모델별로 이미지 생성
|
279 |
+
for idx, model_name in enumerate(selected_models[:4]):
|
280 |
try:
|
281 |
img = query(prompt, model_name, custom_lora, negative_prompt, steps, cfg_scale, seed, strength, width, height)
|
282 |
+
images[idx] = img
|
283 |
+
# 갤러리 업데이트를 위해 중간 결과 반환
|
284 |
+
yield images
|
285 |
except Exception as e:
|
286 |
print(f"Error generating image for {model_name}: {str(e)}")
|
287 |
continue
|
288 |
|
289 |
+
# 남은 슬롯을 마지막 생성된 이미지로 채움
|
290 |
+
last_valid_image = next((img for img in reversed(images) if img is not None), None)
|
291 |
+
if last_valid_image:
|
292 |
+
for i in range(len(images)):
|
293 |
+
if images[i] is None:
|
294 |
+
images[i] = last_valid_image
|
295 |
|
296 |
+
yield images
|
297 |
|
298 |
css = """
|
299 |
footer {
|
|
|
409 |
height="auto"
|
410 |
)
|
411 |
|
412 |
+
|
413 |
+
|
414 |
generate_btn.click(
|
415 |
fn=generate_grid,
|
416 |
inputs=[
|
|
|
425 |
width,
|
426 |
height
|
427 |
],
|
428 |
+
outputs=gallery,
|
429 |
+
every=True # 중간 결과를 실시간으로 업데이트
|
430 |
)
|
431 |
|
432 |
+
|
433 |
def filter_models(search_term):
|
434 |
filtered_models = [m for m in models_list if search_term.lower() in m.lower()]
|
435 |
return gr.update(choices=filtered_models, value=[])
|