mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-11-27 06:40:10 +08:00
9009e25cb1
Co-authored-by: Aarni Koskela <akx@iki.fi>
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
import html
|
|
import json
|
|
import os
|
|
|
|
from modules import shared, ui_extra_networks, sd_models
|
|
|
|
|
|
class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
|
|
def __init__(self):
|
|
super().__init__('Checkpoints')
|
|
|
|
def refresh(self):
|
|
shared.refresh_checkpoints()
|
|
|
|
def list_items(self):
|
|
checkpoint: sd_models.CheckpointInfo
|
|
for index, (name, checkpoint) in enumerate(sd_models.checkpoints_list.items()):
|
|
path, ext = os.path.splitext(checkpoint.filename)
|
|
yield {
|
|
"name": checkpoint.name_for_extra,
|
|
"filename": path,
|
|
"preview": self.find_preview(path),
|
|
"description": self.find_description(path),
|
|
"search_term": self.search_terms_from_path(checkpoint.filename) + " " + (checkpoint.sha256 or ""),
|
|
"onclick": '"' + html.escape(f"""return selectCheckpoint({json.dumps(name)})""") + '"',
|
|
"local_preview": f"{path}.{shared.opts.samples_format}",
|
|
"sort_keys": {'default': index, **self.get_sort_keys(checkpoint.filename)},
|
|
|
|
}
|
|
|
|
def allowed_directories_for_previews(self):
|
|
return [v for v in [shared.cmd_opts.ckpt_dir, sd_models.model_path] if v is not None]
|
|
|