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

feat: Scan wildcard subdirectories #2466

Merged
merged 7 commits into from
Mar 10, 2024
Merged

Conversation

Cruxial0
Copy link
Contributor

@Cruxial0 Cruxial0 commented Mar 6, 2024

Closes #2461

Allows users to sort their wildcards in folders. Previously Fooocus would only search the base directory.

  • Implements functionality for scanning subdirectories within the wildcards directory
  • Adds a function for returning the first occurrence of a file within a directory tree

Adds a method for getting the top-most occurrence of a given file in a directory tree
modules/sdxl_styles.py Outdated Show resolved Hide resolved
modules/util.py Outdated Show resolved Hide resolved
@Cruxial0 Cruxial0 requested a review from mashb1t March 7, 2024 10:59
Cruxial0 and others added 2 commits March 7, 2024 21:12
When using the `name-filter` parameter in `get_model_filenames`, it doesn't guarantee the best match to be in the first index. This change adds a step to ensure the correct wildcard is being loaded.
Copy link
Collaborator

@mashb1t mashb1t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cruxial0 i've added the ability to configure wildcards filepaths incl. caching as the wildcard filepaths were collected every time a wildcard was processed (in the max. 64 iterations for loop).
Please double check so we can merge this feature to develop for the next release.

@mashb1t mashb1t added this to the 2.3.0 (draft) milestone Mar 9, 2024
@mashb1t mashb1t added the Size S small change, basically no testing needed label Mar 9, 2024
@Cruxial0
Copy link
Contributor Author

Cruxial0 commented Mar 9, 2024

Please double check so we can merge this feature to develop for the next release.

Looks good, however I'm not sure how much I like having to refresh files every time a wildcard is added. When I work with wildcards, I tend to add new files frequently. It's by no means a deal-breaker, but I believe it would be more user friendly to update it automatically. Maybe a function that compares the number of files in the wildcard directory at the start of every generation, and only updates if files were added/removed?

@mashb1t
Copy link
Collaborator

mashb1t commented Mar 10, 2024

@Cruxial0 the options are

  • cache content of wildcards, access cached array only => least flexible, but most performant. Downside: linear increase in memory consumption depending on file content of wildcards
  • loading files in apply_wildcards => loaded for each image number iteration
  • same handling as styles_files => only loaded on application start
  • method called before apply_wildcards outside the task loop => list needs to be collected for every generation click
  • store file list in config, reload with reload files button => one time file list processing, allows dynamic content changes while still offering reload without having to restart Fooocus

The changes of this MR now also allow nested directory structures and recursive collection, which is why file counting is not going to work, also one file can be deleted and another added, which is why a simple count isn't sufficient here.

I think the currently implemented option offers the best compromise between performance and flexibility.

@mashb1t mashb1t changed the base branch from main to develop March 10, 2024 20:32
@mashb1t mashb1t merged commit f611718 into lllyasviel:develop Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size S small change, basically no testing needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Scan subdirectories for wildcards
3 participants