Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort Checkpoints and LoRAs alphabetically #1517

Closed
wants to merge 1 commit into from

Conversation

kyeno
Copy link

@kyeno kyeno commented Dec 20, 2023

This simple PR fixes the right menu's "Model" tab to ensure the Checkpoints and Loras are always sorted alphabetically.
Both at startup and after clicking "Refresh All Files" button.

@kyeno kyeno requested a review from lllyasviel as a code owner December 20, 2023 05:11
@mashb1t mashb1t linked an issue Dec 28, 2023 that may be closed by this pull request
@kyeno
Copy link
Author

kyeno commented Jan 2, 2024

@lllyasviel knock knock?

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 6, 2024

as of https://github.com/lllyasviel/Fooocus/blob/main/modules/util.py#L177 models + checkpoints should already be sorted correctly. Can you please double-check if the existing implementation is not working for you and provide a screenshot of your model list + your Gradio model output? Thanks!

@kyeno
Copy link
Author

kyeno commented Jan 7, 2024

@mashb1t Hey! Nope, they're not sorted alphabetically unless that mini PR of mine is implemented.
Here are the screenshots of the main branch:

Screenshot_select-area_20240107103704
Screenshot_select-area_20240107103617

As you can see I have a tendency to rename the LoRAs for some extra management with Fooocus (thinking about making a bigger UI change PR when I get some time), but that's not really an issue.

If this may help you debugging anyhow, my PC is running:

  • Debian Linux 10.X with self-compiled kernel 6.5.8
  • Python 3.11 with pip 23.3.2
  • Official Nvidia driver 535.113.01 with OpenCL 3.0 CUDA 12.2.146
  • Brave Browser 1.61.109 based on Chromium 120.0.6099.144

And HW details (which are likely irrelevant, but who knows at the end):
AMD Ryzen9 5950X 16c/32t @ 5.1GHz, 32GB G.Skill DDR4 3600MHz, EVGA RTX 3090 24GB GDDR6X, 1TB Samsung 980Pro NVMe PCI-Express 4.0 SSD (whole SD engine, models, loras, etc; makes a difference).

@kyeno
Copy link
Author

kyeno commented Jan 7, 2024

Btw also; I'm not a Python expert (yet ;)), but that line you linked could be the culprit. The lambda depending on os.sep may be returning wrong on Linux.
I could test it out a bit in a free while, though I do not have any Windows or Mac machines at the moment for comparison.

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 7, 2024

@kyeno the issue had to do with the condition of the lambda. os.sep returns correctly, but the sorting of the else condition just appends to the end and beginning, which is wrong. I've now implemented sorting for files when walking as well as topdown=False to display subfolders first.

I couldn't change files in your PR, so there now is a separate PR: #1784
Closing this PR & thank you very much for your ideas and your effort, much appreciated 👍

before:
Screenshot 2024-01-07 at 14 17 19

intermediate (2 arrays, one for subdir files, one for root dir files):
Screenshot 2024-01-07 at 13 55 31

after:
Screenshot 2024-01-07 at 14 16 15

@mashb1t mashb1t closed this Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Model list in alphabetical order
2 participants