Commit cf8da8e1 authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #3826 from ANTONIOPSD/patch-1

Natural sorting for dropdown checkpoint list
parents 810e6a40 5d5dc640
...@@ -3,6 +3,7 @@ import os.path ...@@ -3,6 +3,7 @@ import os.path
import sys import sys
from collections import namedtuple from collections import namedtuple
import torch import torch
import re
from omegaconf import OmegaConf from omegaconf import OmegaConf
from ldm.util import instantiate_from_config from ldm.util import instantiate_from_config
...@@ -35,8 +36,10 @@ def setup_model(): ...@@ -35,8 +36,10 @@ def setup_model():
list_models() list_models()
def checkpoint_tiles(): def checkpoint_tiles():
return sorted([x.title for x in checkpoints_list.values()]) 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(): def list_models():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment