File size: 1,157 Bytes
2b6a9b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94aacdd
 
 
 
 
 
 
 
2b6a9b4
 
 
 
 
94aacdd
 
2b6a9b4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import re
import json
import glob
import os

for file in glob.glob("**/*.civitai.info", recursive=True):
    out = {}
    jsonname = re.sub(r"\.civitai\.info$", ".json", file)
    textname = re.sub(r"\.civitai\.info$", ".txt", file)
    if os.path.isfile(jsonname):
        continue
    description = ""
    if os.path.isfile(textname):
        with open(textname) as f:
            description = f.read()
            f.close()

    print(jsonname)
    with open(file) as f:
        info = json.load(f)
    
    sdversion = "Unknown"
    if 'SD 1' in info['baseModel']:
        sdversion = "SD1"
    if 'SD 2' in info['baseModel']:
        sdversion = "SD2"
    if 'SDXL' in info['baseModel']:
        sdversion = "SDXL"
#    out["description"] = info.get("description", "")
#    if not out["description"]:
    out["description"] = description
    out["activation text"] = ", ".join(info["trainedWords"])
    out["notes"] = f"https://civitai.com/models/{info['modelId']}?modelVersionId={info['id']}"
    out["sd version"] = sdversion 
    out["preferred weight"] = 1
    print(jsonname)
    with open(jsonname, "w") as f:
        json.dump(out, f, indent=4)