Hermes Bot commited on
Commit
507359e
·
1 Parent(s): 749e96c

Fix indentation in run_handlers for metadata support

Browse files
Files changed (1) hide show
  1. ui/events/run_handlers.py +17 -17
ui/events/run_handlers.py CHANGED
@@ -97,24 +97,24 @@ def create_run_event(prefix: str, task_type: str, ui_components: dict):
97
  res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery')
98
  if run_btn and res_gal:
99
  def _run_with_meta(*args, progress=gr.Progress(track_tqdm=True)):
100
- # Build UI dict as before
101
- ui_dict = create_ui_inputs_dict(*args)
102
- # Run the pipeline – returns list of file paths
103
- results = generate_image_wrapper(ui_dict, progress)
104
- # If no results, return empty list and empty string
105
- if not results:
106
- return results, ""
107
- # Load metadata from first generated PNG (parameters field)
108
- try:
109
- from PIL import Image
110
- first_img_path = results[0]
111
- with Image.open(first_img_path) as im:
112
- meta = im.info.get('parameters', '')
113
- except Exception as e:
114
- meta = f"(failed to read metadata: {e})"
115
- return results, meta
116
 
117
- run_btn.click(
118
  fn=_run_with_meta,
119
  inputs=input_list_flat,
120
  outputs=[res_gal, ui_components.get(f'metadata_{prefix}')]
 
97
  res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery')
98
  if run_btn and res_gal:
99
  def _run_with_meta(*args, progress=gr.Progress(track_tqdm=True)):
100
+ # Build UI dict as before
101
+ ui_dict = create_ui_inputs_dict(*args)
102
+ # Run the pipeline – returns list of file paths
103
+ results = generate_image_wrapper(ui_dict, progress)
104
+ # If no results, return empty list and empty string
105
+ if not results:
106
+ return results, ""
107
+ # Load metadata from first generated PNG (parameters field)
108
+ try:
109
+ from PIL import Image
110
+ first_img_path = results[0]
111
+ with Image.open(first_img_path) as im:
112
+ meta = im.info.get('parameters', '')
113
+ except Exception as e:
114
+ meta = f"(failed to read metadata: {e})"
115
+ return results, meta
116
 
117
+ run_btn.click(
118
  fn=_run_with_meta,
119
  inputs=input_list_flat,
120
  outputs=[res_gal, ui_components.get(f'metadata_{prefix}')]