enable unloading dataset with single click (#59)

pull/64/head
toshiaki1729 2023-03-20 23:02:23 +09:00 committed by GitHub
parent 6f8abe148a
commit cb8f3a72f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -652,6 +652,9 @@ class DatasetTagEditor(Singleton):
self.tag_tokens.clear()
self.img_idx.clear()
self.dataset_dir = ''
for img in self.images:
if isinstance(img, Image.Image):
img.close()
self.images.clear()

View File

@ -29,6 +29,8 @@ class LoadDatasetUI(UIBase):
self.caption_file_ext = cfg_general.caption_ext
with gr.Column(scale=1, min_width=80):
self.btn_load_datasets = gr.Button(value='Load')
with gr.Column(scale=1, min_width=80):
self.btn_unload_datasets = gr.Button(value='Unload')
with gr.Accordion(label='Dataset Load Settings'):
with gr.Row():
with gr.Column():
@ -94,5 +96,21 @@ class LoadDatasetUI(UIBase):
o_update_filter_and_gallery
)
def unload_files():
dte_instance.clear()
return [
[],
[]
] +\
[gr.CheckboxGroup.update(value=[], choices=[]), 1] +\
filter_by_tags.clear_filters(update_filter_and_gallery) +\
[batch_edit_captions.tag_select_ui_remove.cbg_tags_update()]
self.btn_unload_datasets.click(
fn=unload_files,
outputs=
[dataset_gallery.gl_dataset_images, filter_by_selection.gl_filter_images] +
[dataset_gallery.cbg_hidden_dataset_filter, dataset_gallery.nb_hidden_dataset_filter_apply] +
o_update_filter_and_gallery
)