From 9f14eeee43c2ecd82291c5d07bb4d5d977c026e1 Mon Sep 17 00:00:00 2001 From: Sebastian Ruiz Date: Fri, 25 Feb 2022 15:32:14 +0100 Subject: [PATCH] images are sorted based on number in the image name, so that the order is also preserved without padding like 0001.png etc... --- labelme/app.py | 3 ++- setup.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/labelme/app.py b/labelme/app.py index 43cf86aaa..f72971b66 100644 --- a/labelme/app.py +++ b/labelme/app.py @@ -6,6 +6,7 @@ import os.path as osp import re import webbrowser +import regex import imgviz from qtpy import QtCore @@ -2075,5 +2076,5 @@ def scanAllImages(self, folderPath): if file.lower().endswith(tuple(extensions)): relativePath = osp.join(root, file) images.append(relativePath) - images.sort(key=lambda x: x.lower()) + images.sort(key=lambda f: int(regex.sub('\D', '', f.lower()))) return images diff --git a/setup.py b/setup.py index cd8fa90ae..02cf37721 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,7 @@ def get_install_requires(): "PyYAML", "qtpy!=1.11.2", "termcolor", + "regex", ] # Find python binding for qt with priority: