diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-29 05:02:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-29 05:02:03 +0000 |
commit | cf8da8e1b0b8a4ea75c66ed4657f409cadab2c59 (patch) | |
tree | 7ab1003877c91469f8d49f619c72b15f1ed8a7c5 | |
parent | 810e6a407d06f26a4b2d8ebe88dc54c426143d27 (diff) | |
parent | 5d5dc64064d8ca399a76fe44dbb62bdef6c4b7c4 (diff) | |
download | stable-diffusion-webui-gfx803-cf8da8e1b0b8a4ea75c66ed4657f409cadab2c59.tar.gz stable-diffusion-webui-gfx803-cf8da8e1b0b8a4ea75c66ed4657f409cadab2c59.tar.bz2 stable-diffusion-webui-gfx803-cf8da8e1b0b8a4ea75c66ed4657f409cadab2c59.zip |
Merge pull request #3826 from ANTONIOPSD/patch-1
Natural sorting for dropdown checkpoint list
-rw-r--r-- | modules/sd_models.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/sd_models.py b/modules/sd_models.py index e697bb72..64d5ee0d 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -3,6 +3,7 @@ import os.path import sys
from collections import namedtuple
import torch
+import re
from omegaconf import OmegaConf
from ldm.util import instantiate_from_config
@@ -35,8 +36,10 @@ def setup_model(): list_models()
-def checkpoint_tiles():
- return sorted([x.title for x in checkpoints_list.values()])
+def checkpoint_tiles():
+ convert = lambda name: int(name) if name.isdigit() else name.lower()
+ alphanumeric_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
+ return sorted([x.title for x in checkpoints_list.values()], key = alphanumeric_key)
def list_models():
|