CivArchive
    ← All articles
    Published August 11, 2024by BigDaddyAI

    Create yaml wildcard from loras directory

    122 views2 reactions0 comments on CivitAI5 collected
    tool guide

    Create yaml wildcard from loras directory

    Step-by-Step Usage:

    1. Download the python file where you want

    2. If it is the by_filename

      In the Stable Diffusion parameters change refer to Lora by Filename. By this way there is no chance to encounter lora name errors !

    3. Running Time:

      Execute with:

      python loras_to_yaml_wildcard.py
      OR
      python loras_to_yaml_wildcard_by_filename.py

      Choose the directory with the loras inside (a directory with subdirectory, see the example)

    4. Running a second time:

      Same running time but you can use the precedent path to the loras directory

    Specifications:

    If there is a ".json" file associates with the lora, the positive prompt and the weight are taken from this one.

    By default the positive prompt is "" and the weight is 1.

    Concerning a possible rename, the name of activation is taken in the ".civitai.info" file if it exists.

    By the way, a weight of 0 is set automatically to 1.

    Example:

    Suppose you have the following directory structure:

    Lora/
    ├── characters
    |    ├── lora1.safetensors
    |    └── lora2.safetensors
    ├── positions
    |    ├── lora1.safetensors
    |    └── lora2.safetensors
    ├── styles
    |    └── lora.safetensors
    └── sliders
        ├── lora1.safetensors
        └── lora2.safetensors

    The output loras.yaml will produce a YAML file structured like this: (the bracket doesn't exist)

    loras:
      characters:
        - <lora:{lora_name}:{weight}> {positive_prompt}
        - <lora:{lora_name}:{weight}> {positive_prompt}
      positions:
        - <lora:{lora_name}:{weight}> {positive_prompt}
      styles:
        - <lora:{lora_name}:{weight}> {positive_prompt}
        - <lora:{lora_name}:{weight}> {positive_prompt}
      sliders
        - <lora:{lora_name}:{weight}> {positive_prompt}

    Troubleshooting:

    • Ensure that all required libraries (pyyaml, tqdm, and tkinter) are installed. You can install any missing libraries using pip.

    • If you encounter issues, try running the script with administrative privileges to ensure it has the necessary permissions to read and write files.

    Attachments