Spaces:
Sleeping
Sleeping
Fix model image list to grid type
Browse files
app.py
CHANGED
|
@@ -197,8 +197,8 @@ def load_image_from_url(url):
|
|
| 197 |
return None
|
| 198 |
|
| 199 |
|
| 200 |
-
#URL ์
๋ ฅ ์ฒ๋ฆฌ ํจ์
|
| 201 |
def process_url_image(url):
|
|
|
|
| 202 |
if not url or not url.strip():
|
| 203 |
return None
|
| 204 |
|
|
@@ -211,14 +211,25 @@ def process_url_image(url):
|
|
| 211 |
except Exception as e:
|
| 212 |
print(f"Error parsing URL: {e}")
|
| 213 |
return None
|
| 214 |
-
|
| 215 |
img = load_image_from_url(url)
|
| 216 |
if img is None:
|
| 217 |
print("Failed to load image from URL")
|
| 218 |
return None
|
| 219 |
-
|
| 220 |
return preprocess_image(img)
|
| 221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
def download_model_file(model_path, urls):
|
| 224 |
"""Download model file from multiple URLs if it doesn't exist"""
|
|
@@ -453,13 +464,8 @@ garm_list_path = [os.path.join(example_path,"cloth",garm) for garm in garm_list]
|
|
| 453 |
human_list = os.listdir(os.path.join(example_path,"human"))
|
| 454 |
human_list_path = [os.path.join(example_path,"human",human) for human in human_list]
|
| 455 |
|
| 456 |
-
human_ex_list
|
| 457 |
-
|
| 458 |
-
ex_dict= {}
|
| 459 |
-
ex_dict['background'] = ex_human
|
| 460 |
-
ex_dict['layers'] = None
|
| 461 |
-
ex_dict['composite'] = None
|
| 462 |
-
human_ex_list.append(ex_dict)
|
| 463 |
|
| 464 |
##default human
|
| 465 |
|
|
@@ -479,7 +485,8 @@ with image_blocks as demo:
|
|
| 479 |
example = gr.Examples(
|
| 480 |
inputs=imgs,
|
| 481 |
examples_per_page=8,
|
| 482 |
-
examples=human_ex_list
|
|
|
|
| 483 |
)
|
| 484 |
|
| 485 |
with gr.Column():
|
|
|
|
| 197 |
return None
|
| 198 |
|
| 199 |
|
|
|
|
| 200 |
def process_url_image(url):
|
| 201 |
+
"""Process image from URL and return PIL Image"""
|
| 202 |
if not url or not url.strip():
|
| 203 |
return None
|
| 204 |
|
|
|
|
| 211 |
except Exception as e:
|
| 212 |
print(f"Error parsing URL: {e}")
|
| 213 |
return None
|
| 214 |
+
|
| 215 |
img = load_image_from_url(url)
|
| 216 |
if img is None:
|
| 217 |
print("Failed to load image from URL")
|
| 218 |
return None
|
| 219 |
+
|
| 220 |
return preprocess_image(img)
|
| 221 |
|
| 222 |
+
def load_example_for_editor(image_path):
|
| 223 |
+
"""Load example image for ImageEditor component"""
|
| 224 |
+
if image_path is None:
|
| 225 |
+
return None
|
| 226 |
+
|
| 227 |
+
# ImageEditor๋ ํน์ ํ์์ ๊ธฐ๋ํ๋ฏ๋ก ๋์
๋๋ฆฌ ํํ๋ก ๋ฐํ
|
| 228 |
+
return {
|
| 229 |
+
"background": image_path,
|
| 230 |
+
"layers": None,
|
| 231 |
+
"composite": None
|
| 232 |
+
}
|
| 233 |
|
| 234 |
def download_model_file(model_path, urls):
|
| 235 |
"""Download model file from multiple URLs if it doesn't exist"""
|
|
|
|
| 464 |
human_list = os.listdir(os.path.join(example_path,"human"))
|
| 465 |
human_list_path = [os.path.join(example_path,"human",human) for human in human_list]
|
| 466 |
|
| 467 |
+
# human_ex_list๋ฅผ ๋จ์ํ ์ด๋ฏธ์ง ๊ฒฝ๋ก ๋ฆฌ์คํธ๋ก ๋ณ๊ฒฝ (๊ทธ๋ฆฌ๋ ํ์๋ฅผ ์ํด)
|
| 468 |
+
human_ex_list = human_list_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
|
| 470 |
##default human
|
| 471 |
|
|
|
|
| 485 |
example = gr.Examples(
|
| 486 |
inputs=imgs,
|
| 487 |
examples_per_page=8,
|
| 488 |
+
examples=human_ex_list,
|
| 489 |
+
fn=load_example_for_editor
|
| 490 |
)
|
| 491 |
|
| 492 |
with gr.Column():
|