aifeifei798's picture
Update feifeilib/feifeiprompt.py
246eab5 verified
raw
history blame
2.17 kB
import numpy as np
import random
import re
import torch
import config
with open("artist.txt", "r") as file:
artists = file.readlines()
MAX_SEED = np.iinfo(np.int32).max
# 去除每行末尾的换行符
artists = [artist.strip() for artist in artists]
def feifeiprompt(randomize_seed,seed,prompt,quality_select,styles_Radio,FooocusExpansion_select):
# 处理随机种子
if randomize_seed:
seed = random.randint(0, MAX_SEED)
else:
seed = int(seed) # Ensure seed is an integer
generator = torch.Generator().manual_seed(seed)
if not prompt:
prompt = "the photo is a 18 yo jpop girl is looking absolutely adorable and gorgeous, with a playful and mischievous grin, her eyes twinkling with joy. art by __artist__ and __artist__"
if "__artist__" in prompt:
# 随机选择艺术家
selected_artists = random.sample(artists, len(artists))
# 使用正则表达式替换所有的 __artist__
def replace_artists(match):
return selected_artists.pop(0)
prompt = re.sub(r"__artist__", replace_artists, prompt)
if quality_select:
prompt += ", masterpiece, best quality, very aesthetic, absurdres"
if FooocusExpansion_select:
prompt = re.sub("girl", " feifei, A beautiful, 18 yo kpop idol, large-busted Japanese slim girl, with light makeup, gazing deeply into the camera, " ,prompt)
prompt = re.sub("young woman", " feifei, A beautiful, 18 yo kpop idol, large-busted Japanese slim girl, with light makeup, gazing deeply into the camera, " ,prompt)
prompt = re.sub("woman", " feifei, A beautiful, 18 yo kpop idol, large-busted Japanese slim girl, with light makeup, gazing deeply into the camera, " ,prompt)
prompt = re.sub("model", " feifei, A beautiful, 18 yo kpop idol, large-busted Japanese slim girl, with light makeup, gazing deeply into the camera, " ,prompt)
if styles_Radio:
for style_name in styles_Radio:
for style in config.style_list:
if style["name"] == style_name:
prompt = style["prompt"].replace("{prompt}", prompt)
return prompt,generator