sketch2lineart / utils /prompt_utils.py
tori29umai's picture
app.py
3542be4
raw
history blame
No virus
1.09 kB
def remove_duplicates(base_prompt):
# ใ‚ฟใ‚ฐใฎ้‡่ค‡ใ‚’ๅ–ใ‚Š้™คใ
prompt_list = base_prompt.split(", ")
seen = set()
unique_tags = []
for tag in prompt_list :
tag_clean = tag.lower().strip()
if tag_clean not in seen and tag_clean != "":
unique_tags.append(tag)
seen.add(tag_clean)
return ", ".join(unique_tags)
def remove_color(base_prompt):
# ใ‚ฟใ‚ฐใฎ่‰ฒๆƒ…ๅ ฑใ‚’ๅ–ใ‚Š้™คใ
prompt_list = base_prompt.split(", ")
color_list = ["pink", "red", "orange", "brown", "yellow", "green", "blue", "purple", "blonde", "colored skin", "white hair"]
# ใ‚ซใƒฉใƒผใ‚ฟใ‚ฐใ‚’้™คๅŽปใ—ใพใ™ใ€‚
cleaned_tags = [tag for tag in prompt_list if all(color.lower() not in tag.lower() for color in color_list)]
return ", ".join(cleaned_tags)
def execute_prompt(execute_tags, base_prompt):
prompt_list = base_prompt.split(", ")
# execute_tagsใ‚’้™คๅŽป
filtered_tags = [tag for tag in prompt_list if tag not in execute_tags]
# ๆœ€็ต‚็š„ใชใƒ—ใƒญใƒณใƒ—ใƒˆใ‚’็”Ÿๆˆ
return ", ".join(filtered_tags)