Spaces:
Running
on
Zero
Running
on
Zero
Add error handling to Gallery instantiation
Browse files- app.py +5 -1
- utils/image_utils.py +7 -0
app.py
CHANGED
|
@@ -26,6 +26,9 @@ from trellis.representations import Gaussian, MeshExtractResult
|
|
| 26 |
from trellis.utils import render_utils, postprocessing_utils
|
| 27 |
from pathlib import Path
|
| 28 |
import utils.hex_hura as hex_hura
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
import logging
|
| 31 |
#logging.getLogger("transformers.modeling_utils").setLevel(logging.ERROR)
|
|
@@ -59,6 +62,7 @@ from utils.image_utils import (
|
|
| 59 |
change_color,
|
| 60 |
blur_image,
|
| 61 |
open_image,
|
|
|
|
| 62 |
upscale_image,
|
| 63 |
lerp_imagemath,
|
| 64 |
shrink_and_paste_on_blank,
|
|
@@ -1498,7 +1502,7 @@ with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty',
|
|
| 1498 |
)
|
| 1499 |
with gr.Accordion("Choose Image Style*", open=True):
|
| 1500 |
lora_gallery = gr.Gallery(
|
| 1501 |
-
[(
|
| 1502 |
label="Styles",
|
| 1503 |
allow_preview=False, preview=False ,
|
| 1504 |
columns=2,
|
|
|
|
| 26 |
from trellis.utils import render_utils, postprocessing_utils
|
| 27 |
from pathlib import Path
|
| 28 |
import utils.hex_hura as hex_hura
|
| 29 |
+
from utils.storage import (
|
| 30 |
+
upload_files_to_repo
|
| 31 |
+
)
|
| 32 |
|
| 33 |
import logging
|
| 34 |
#logging.getLogger("transformers.modeling_utils").setLevel(logging.ERROR)
|
|
|
|
| 62 |
change_color,
|
| 63 |
blur_image,
|
| 64 |
open_image,
|
| 65 |
+
try_open_image,
|
| 66 |
upscale_image,
|
| 67 |
lerp_imagemath,
|
| 68 |
shrink_and_paste_on_blank,
|
|
|
|
| 1502 |
)
|
| 1503 |
with gr.Accordion("Choose Image Style*", open=True):
|
| 1504 |
lora_gallery = gr.Gallery(
|
| 1505 |
+
[(img, title) for image_path, title in lora_models if (img := try_open_image(image_path)) is not None],
|
| 1506 |
label="Styles",
|
| 1507 |
allow_preview=False, preview=False ,
|
| 1508 |
columns=2,
|
utils/image_utils.py
CHANGED
|
@@ -69,6 +69,13 @@ def get_image_from_dict(image_path):
|
|
| 69 |
else:
|
| 70 |
return image_path, False
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
def open_image(image_path):
|
| 73 |
"""
|
| 74 |
Opens an image from a file path or URL, or decodes a DataURL string into an image.
|
|
|
|
| 69 |
else:
|
| 70 |
return image_path, False
|
| 71 |
|
| 72 |
+
def try_open_image(image_path):
|
| 73 |
+
try:
|
| 74 |
+
return open_image(image_path)
|
| 75 |
+
except Exception as e:
|
| 76 |
+
print(f"Skipping image {image_path} due to error: {e}")
|
| 77 |
+
return None
|
| 78 |
+
|
| 79 |
def open_image(image_path):
|
| 80 |
"""
|
| 81 |
Opens an image from a file path or URL, or decodes a DataURL string into an image.
|