初始化项目,由ModelHub XC社区提供模型
Model: FredZhang7/anime-anything-promptgen-v2 Source: Original Platform
This commit is contained in:
33
preprocess.py
Normal file
33
preprocess.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import re
|
||||
|
||||
def clean_tags(tags):
|
||||
# Make tags more human readable
|
||||
tags = tags.replace(' ', ', ').replace('_', ' ')
|
||||
|
||||
# Remove "!", "?", ".", "(", ")" from the tags
|
||||
tags = re.sub(r"[!.?()]", "", tags)
|
||||
|
||||
# Replace " , " with an empty space
|
||||
tags = re.sub(r" , ", " ", tags)
|
||||
|
||||
# Remove any trailing commas
|
||||
tags = re.sub(r"^,|,$", "", tags)
|
||||
|
||||
# Strip spaces
|
||||
tags = tags.strip()
|
||||
|
||||
# Remove any usernames
|
||||
words = tags.split(", ")
|
||||
result = []
|
||||
for word in words:
|
||||
word = word.strip()
|
||||
if word == 'v':
|
||||
result.append(word)
|
||||
continue
|
||||
if len(word) < 2:
|
||||
continue
|
||||
if any(char.isdigit() for char in word) and word not in ["1girl", "1boy", "1koma", "1other"]:
|
||||
continue
|
||||
result.append(word)
|
||||
|
||||
return ", ".join(result)
|
||||
Reference in New Issue
Block a user