TomyAI commited on
Commit
21e468b
1 Parent(s): 3256f40

Update civitaiinfo_convert.py

Browse files
Files changed (1) hide show
  1. civitaiinfo_convert.py +29 -29
civitaiinfo_convert.py CHANGED
@@ -4,37 +4,37 @@ import glob
4
  import os
5
 
6
  for file in glob.glob("**/*.civitai.info", recursive=True):
7
- out = {}
8
- jsonname = re.sub(r"\.civitai\.info$", ".json", file)
9
- textname = re.sub(r"\.civitai\.info$", ".txt", file)
10
- if os.path.isfile(jsonname):
11
- continue
12
- description = ""
13
- if os.path.isfile(textname):
14
- with open(textname) as f:
15
- description = f.read()
16
- f.close()
17
-
18
  try:
 
 
 
 
 
 
 
 
 
 
 
19
  with open(file) as f:
20
  info = json.load(f)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  except:
22
- print("ERROR: json load error :", jsonname)
23
  continue
24
- print("Processing :",jsonname)
25
- sdversion = "Unknown"
26
- if 'SD 1' in info['baseModel']:
27
- sdversion = "SD1"
28
- if 'SD 2' in info['baseModel']:
29
- sdversion = "SD2"
30
- if 'SDXL' in info['baseModel']:
31
- sdversion = "SDXL"
32
- # out["description"] = info.get("description", "")
33
- # if not out["description"]:
34
- out["description"] = description
35
- out["activation text"] = ", ".join(info["trainedWords"])
36
- out["notes"] = f"https://civitai.com/models/{info['modelId']}?modelVersionId={info['id']}"
37
- out["sd version"] = sdversion
38
- out["preferred weight"] = 1
39
- with open(jsonname, "w") as f:
40
- json.dump(out, f, indent=4)
 
4
  import os
5
 
6
  for file in glob.glob("**/*.civitai.info", recursive=True):
 
 
 
 
 
 
 
 
 
 
 
7
  try:
8
+ out = {}
9
+ jsonname = re.sub(r"\.civitai\.info$", ".json", file)
10
+ textname = re.sub(r"\.civitai\.info$", ".txt", file)
11
+ if os.path.isfile(jsonname):
12
+ continue
13
+ description = ""
14
+ if os.path.isfile(textname):
15
+ with open(textname) as f:
16
+ description = f.read()
17
+ f.close()
18
+
19
  with open(file) as f:
20
  info = json.load(f)
21
+ print("Processing :",jsonname)
22
+ sdversion = "Unknown"
23
+ if 'SD 1' in info['baseModel']:
24
+ sdversion = "SD1"
25
+ if 'SD 2' in info['baseModel']:
26
+ sdversion = "SD2"
27
+ if 'SDXL' in info['baseModel']:
28
+ sdversion = "SDXL"
29
+ # out["description"] = info.get("description", "")
30
+ # if not out["description"]:
31
+ out["description"] = description
32
+ out["activation text"] = ", ".join(info["trainedWords"])
33
+ out["notes"] = f"https://civitai.com/models/{info['modelId']}?modelVersionId={info['id']}"
34
+ out["sd version"] = sdversion
35
+ out["preferred weight"] = 1
36
+ with open(jsonname, "w") as f:
37
+ json.dump(out, f, indent=4)
38
  except:
39
+ print("ERROR :", file)
40
  continue