CivArchive
    ← All articles
    Published October 18, 2024by zentrocdot

    LoRA , Metadata and the Metadata Tag ss_output_name

    133 views2 reactions0 comments on CivitAI0 collected
    pythonmetadatatagloratool guidetool

    Preface

    While working on the creation on LoRA models I figured out a strangeness. I was thinking, that it was a strangeness, but it was not. A look at the metadata of a LoRA revealed that there is a tag corresponding to the file name. Instead of using the LoRA filename from the directory where the LoRA is located AUTOMATIC1111 took in some cases the LoRA filename from the metadata. Both is working at all, but confusing if one works with a lot of LoRAs as well as a lot of variations of the same LoRA.

    Any solution that is not automated is prone to errors. The existing file should always be modified accordingly. In my first attempts to modify the filename in the metadata, the file looked afterwards good, but the LoRA was no longer usable. My current Python script handles the modification very reliably for the moment.

    Problem Description

    When one is using a LoRA in a Prompt this looks like:

    apple in a bottle, <lora:AppleBottle:1>

    The last expression characterises the usage of a LoRA as follows:

    <lora:FILENAME:WEIGHT>

    In the first shot, this will be the filename from the directory structure, in the second shot it may be the name from the metadata.

    What the Python Script Does

    The Python script uses the given filename without extension and changes the tag

    ss_output_name

    in a way, that tag and filename afterwards are matching.

    Afterwards one can use the filename by typing in in the Prompt or selecting the file from the file selector and the entry in the Prompt is always correct.

    Programme Implementation

    The script which allows to change the tag can be found on GitHub [1]. At the moment the script is experimental. If one likes to use the script, one needs to edit the script and has to change the filename.

    For paranoia reasons, the script creates a backup copy, which I have not needed so far.

    Side Notes

    To check my LoRA models as well as other LoRA models with respect to the metadata one can use my AUTOMATIC1111 Extension I have written for this task [2].

    I personally don't like the official Extension that is available for AUTOMATIC1111, as the risk of changing more than necessary is too great for me.

    I like all the time straightforward solutions, simple to understand and simple to use, without the possibilities to make too much mistakes.

    Final Words

    Have a nice day. Have fun. Be inspired!

    Reference

    [1] https://github.com/zentrocdot/artificial-intelligence-tools/blob/main/python/modify_lora_output_name.py

    [2] https://github.com/zentrocdot/sd-webui-lora_metadata_viewer