위 파일 이미지저장해서 .zip으로 바꿔서 압축풀면된다.

다들 파이썬은 설치되있으니까 실행은 알아서 가능할거라 믿는다.


<선행필수 - civitai helper로 스캔한번 해놔야함>

압축풀면 values.txt(로라가중치 와일드카드) 랑 allloraTrigger.py있는데. 와일드카드 폴더에 두개다 넣어두고.

파이썬 실행하고 로라있는 폴더지정하면 알아서 로라랑

civitiai.info 파일을 확인해서 lora+트리거워드(있는경우) 합쳐서 와일드카드 만들어줌. 


__allloratrigger__ 로 와일드카드 실행하면. 

랜덤 로라(해당 로라의 트리거워드 포함)+가중치랜덤 으로 결과물이 나온다.

여기다가 마음대로 태그 추가해서 하거나, 괜찮게나온 로라 확인해서 그거 중심으로 돌리거나

그냥 계속 랜덤가챠 돌릴수있음. 


잘안되면 코드 아래 붙여둘태니까 알아서 가져다쓰셈. 

구글 Bard시켜서 수정한거니까 알아서 수정해서 써도됨.

------------------------------------------------------------------

import os

import json

from tkinter import filedialog


wildcardname = "allloratrigger.txt"

emptyLora = "trained_word_empty.txt"


# 사용자로부터 폴더를 입력 받습니다.

folder = filedialog.askdirectory()


# .safetensors와 .ckpt 확장자를 가진 파일 목록을 가져옵니다.

files = [f for f in os.listdir(folder) if f.endswith(".safetensors") or f.endswith(".ckpt")]


# .txt 파일을 초기화합니다.

with open(wildcardname, "w", encoding="utf-8") as f:

    f.write("")

with open(emptyLora, "w", encoding="utf-8") as f:

    f.write("")


# 각 파일에 대해 filename+.civitai.info 파일이 있는지 확인합니다.

for file in files:

    print(file)

    info_file = os.path.join(folder, os.path.splitext(file)[0] + ".civitai.info")

    if os.path.exists(info_file):

        try:

            # 파일을 열고 traindWords 값을 가져옵니다.

            with open(info_file, "r", encoding="utf-8") as f:

                info = json.load(f)

                trained_words = info.get("trainedWords", [])

                

                if(0<len(trained_words)):

                    # traindWords 값을 파일에 저장합니다. 형식: 파일명 (확장자 제외), traindWords 값

                    with open(wildcardname, "a", encoding="utf-8") as f:

                        if file.endswith(".safetensors") or file.endswith(".ckpt"):

                            f.write("<lora:"+os.path.splitext(file)[0] + ":__values__>," + ",".join(trained_words) + "\n")

                else:

                    # traindWords 값을 파일에 저장합니다. 형식: 파일명 (확장자 제외), traindWords 값

                    with open(wildcardname, "a", encoding="utf-8") as f:

                        if file.endswith(".safetensors") or file.endswith(".ckpt"):

                            f.write("<lora:"+os.path.splitext(file)[0] + ":__values__>"+"\n")

                    with open(emptyLora, "a", encoding="utf-8") as f:

                        if file.endswith(".safetensors") or file.endswith(".ckpt"):

                            f.write(os.path.splitext(file)[0]+"\n")

        except json.JSONDecodeError as e:

            print("JSONDecodeError occurred:", str(e))

            # 오류 처리 코드 추가

            # 예를 들어, 해당 파일을 건너뛰거나 오류 로그를 기록하고 다음 파일로 진행할 수 있습니다.

# 프로그램이 종료되지 않도록 입력을 대기합니다.

print("Triggerword가 없는 모델은 다음 파일에 기록되었습니다 - " + emptyLora)

input("아무키나 누르면 종료...")