forked from wochenlong/nai3_train
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_characetrs.py
44 lines (32 loc) · 1.77 KB
/
random_characetrs.py
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
39
40
41
42
43
44
import json
from generator.basic_novelai_image_generator import BasicNovelaiImageGenerator
from prompter.fetcher.chara_prompt_fetcher import CharacterPromptFetcher
from prompter.fetcher.basic_prompt_fetcher import EmptyFetcher, SingleItemFetcher
from prompter.fetcher.quality_prompt_fetcher import QualityPromptFetcher
from prompter.fetcher.setting.solo_prompt_fetcher import SoloPromptFetcher
from prompter.fetcher.state.wardrobe_malfunction import WardrobeMalfunctionPromptFetcher
from prompter.prompt_builder import PromptBuilder
from batch_generator import BatchImageGenerator
characters_path = r".\json\role\base_role.json"
def load_config(path):
with open(path, 'r') as file:
return json.load(file)
config_path = r'.\config.json' # 配置文件路径
config = load_config(config_path)
token = config.get('token', '') # 如果配置文件中没有token,返回空字符串
# 生成多张图像并保存
generator = BasicNovelaiImageGenerator(token)
chara_fetcher = CharacterPromptFetcher(filepath=characters_path, random_mode=False)
quality_fetcher = QualityPromptFetcher()
solo_fetcher = SoloPromptFetcher()
empty_fetcher = EmptyFetcher()
shouukun = SingleItemFetcher("{fukuro_daizi},[naga_u,henreader],[[ask_(askzy),ama_mitsuki]],mikozin,{kaede_(sayappa),goldowl},[wlop,nekojira],[[ke-ta,mignon]],{{teranekosu,gin00}},year_2023,")
wardrobe_malfunction = WardrobeMalfunctionPromptFetcher()
# 人物词+风格词+镜头词/环境词+人物特征描写+动作词+质量词
prompt_builder = PromptBuilder([chara_fetcher], [shouukun], [solo_fetcher],
[wardrobe_malfunction], [empty_fetcher], [quality_fetcher])
batch_generator = BatchImageGenerator(
image_generator=generator,
prompt_builder=prompt_builder
)
batch_generator.generate_batch()