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

Improper Filename Sanitation Prevents LoRA Detection #115

Open
Astronox opened this issue Nov 12, 2023 · 1 comment
Open

Improper Filename Sanitation Prevents LoRA Detection #115

Astronox opened this issue Nov 12, 2023 · 1 comment

Comments

@Astronox
Copy link

Noticed that my LoRAs that have parentheses in their filenames weren't properly listed in the image metadata.

To recreate this bug:
-Create an image with a LoRA from civitai (one that you are sure is properly added to the metadata, and is detected when uploading the image to civitai).
-Close your instance of stable diffusion and rename the filename of the LoRA adding "(test)" or something similar
-Make an image with that same LoRA

The new image should not have the LoRA's hash value in the metadata.

I've noticed similar behavior with too many hyphens in the filename, too many double hyphens in the filename, filenames that are too long (potential issue with max filename path length?), and filenames that are significantly different from the default filename found on civitai.

I suspect that whatever function is used in this extension for generating hash values throws an exception when given a filename with parentheses, which is then caught and suppressed, so no hash is generated.

If the bug can't be recreated, let me know and I can generate some images on my end to provide examples.

@ComplexRobot
Copy link

I've run into this issue myself. Looking at the code, the lora prompt text must fit the regex pattern <(lora|hypernet):([a-zA-Z0-9_\.\-\s]+):([0-9.]+)(?:[:].*)?> to be properly parsed and written to the metadata.
In other words, the lora name can only contain letters, numbers, underscores, periods, hyphens and white space. The actual prompt is not that restrictive.
Also, it uses the filename for the lookup so the lora string must be the filename, not the internal name. (There is a setting to insert the names as their filename.)
And the hashes are written at startup, so after renaming the file you have to completely restart the UI.

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

No branches or pull requests

2 participants