Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -349,8 +349,7 @@ def on_change_prompt(img: Image.Image | None, prompt: str | None, bg_prompt: str
|
|
349 |
def process_prompt(img: Image.Image, prompt: str, bg_prompt: str | None = None,
|
350 |
aspect_ratio: str = "1:1", position: str = "bottom-center",
|
351 |
scale_percent: float = 100) -> tuple[Image.Image, Image.Image]:
|
352 |
-
try:
|
353 |
-
|
354 |
if img is None or prompt.strip() == "":
|
355 |
raise gr.Error("Please provide both image and prompt")
|
356 |
|
@@ -365,7 +364,6 @@ def process_prompt(img: Image.Image, prompt: str, bg_prompt: str | None = None,
|
|
365 |
|
366 |
results, _ = _process(img, prompt, bg_prompt, aspect_ratio)
|
367 |
|
368 |
-
|
369 |
if bg_prompt:
|
370 |
try:
|
371 |
print(f"Using position: {position}") # ๋๋ฒ๊น
์ฉ
|
@@ -383,14 +381,17 @@ def process_prompt(img: Image.Image, prompt: str, bg_prompt: str | None = None,
|
|
383 |
position=position,
|
384 |
scale_percent=scale_percent
|
385 |
)
|
386 |
-
|
387 |
return combined, results[2]
|
388 |
except Exception as e:
|
389 |
print(f"Combination error: {str(e)}")
|
390 |
return results[1], results[2]
|
391 |
|
392 |
-
# ์ด ๋ถ๋ถ์ด ๋๋ฝ๋์์ต๋๋ค
|
393 |
return results[1], results[2] # ๊ธฐ๋ณธ ๋ฐํ ์ถ๊ฐ
|
|
|
|
|
|
|
|
|
|
|
394 |
|
395 |
|
396 |
def process_bbox(img: Image.Image, box_input: str) -> tuple[Image.Image, Image.Image]:
|
|
|
349 |
def process_prompt(img: Image.Image, prompt: str, bg_prompt: str | None = None,
|
350 |
aspect_ratio: str = "1:1", position: str = "bottom-center",
|
351 |
scale_percent: float = 100) -> tuple[Image.Image, Image.Image]:
|
352 |
+
try:
|
|
|
353 |
if img is None or prompt.strip() == "":
|
354 |
raise gr.Error("Please provide both image and prompt")
|
355 |
|
|
|
364 |
|
365 |
results, _ = _process(img, prompt, bg_prompt, aspect_ratio)
|
366 |
|
|
|
367 |
if bg_prompt:
|
368 |
try:
|
369 |
print(f"Using position: {position}") # ๋๋ฒ๊น
์ฉ
|
|
|
381 |
position=position,
|
382 |
scale_percent=scale_percent
|
383 |
)
|
|
|
384 |
return combined, results[2]
|
385 |
except Exception as e:
|
386 |
print(f"Combination error: {str(e)}")
|
387 |
return results[1], results[2]
|
388 |
|
|
|
389 |
return results[1], results[2] # ๊ธฐ๋ณธ ๋ฐํ ์ถ๊ฐ
|
390 |
+
except Exception as e:
|
391 |
+
print(f"Error in process_prompt: {str(e)}")
|
392 |
+
raise gr.Error(str(e))
|
393 |
+
finally:
|
394 |
+
clear_memory()
|
395 |
|
396 |
|
397 |
def process_bbox(img: Image.Image, box_input: str) -> tuple[Image.Image, Image.Image]:
|