Hermes Bot commited on
Commit
a79dfdb
·
1 Parent(s): 478118a

Flatten selected_path recursively to get image path and improve debug

Browse files
Files changed (1) hide show
  1. ui/events/run_handlers.py +5 -3
ui/events/run_handlers.py CHANGED
@@ -118,9 +118,11 @@ def create_run_event(prefix: str, task_type: str, ui_components: dict):
118
  def _show_meta(selected_path, *_):
119
  # `selected_path` may be a string (filepath) or a list/tuple of filepaths.
120
  try:
121
- # Normalise to a single path (first element if it's a tuple/list)
122
- path = selected_path[0] if isinstance(selected_path, (list, tuple)) else selected_path
123
- print(f"[DEBUG] Normalised gallery path: {path}")
 
 
124
  from PIL import Image
125
  with Image.open(path) as im:
126
  meta = im.info.get("parameters", "")
 
118
  def _show_meta(selected_path, *_):
119
  # `selected_path` may be a string (filepath) or a list/tuple of filepaths.
120
  try:
121
+ # Recursively flatten until we get a string path
122
+ path = selected_path
123
+ while isinstance(path, (list, tuple)) and len(path) > 0:
124
+ path = path[0]
125
+ print(f"[DEBUG] Extracted image path: {path}")
126
  from PIL import Image
127
  with Image.open(path) as im:
128
  meta = im.info.get("parameters", "")