Hermes Bot commited on
Commit
4ade1be
·
1 Parent(s): d2de2a3

Add select handler to display generation info for chosen gallery image

Browse files
Files changed (1) hide show
  1. ui/events/run_handlers.py +14 -3
ui/events/run_handlers.py CHANGED
@@ -104,7 +104,18 @@ def create_run_event(prefix: str, task_type: str, ui_components: dict):
104
  # No need to add it to the run button outputs.
105
 
106
  run_btn.click(
107
- fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress),
108
  inputs=input_list_flat,
109
- outputs=outputs
110
- )
 
 
 
 
 
 
 
 
 
 
 
 
104
  # No need to add it to the run button outputs.
105
 
106
  run_btn.click(
107
+ fn=_run_with_meta,
108
  inputs=input_list_flat,
109
+ outputs=[res_gal, ui_components.get(f'metadata_{prefix}')]
110
+ )
111
+ # When a user selects an image from the gallery, load its generation info
112
+ def _show_meta(selected_path, *_):
113
+ try:
114
+ from PIL import Image
115
+ with Image.open(selected_path) as im:
116
+ meta = im.info.get('parameters', '')
117
+ except Exception:
118
+ meta = ''
119
+ return meta
120
+ # Connect the select event of the gallery to update the metadata textbox
121
+ res_gal.select(fn=_show_meta, inputs=res_gal, outputs=ui_components.get(f'metadata_{prefix}'))