From c4f24aba47cb7d2b81b5219799a5764b222539d8 Mon Sep 17 00:00:00 2001 From: HeathWang Date: Wed, 30 Aug 2023 17:21:38 +0800 Subject: [PATCH] add body skin function --- promptsModules/basePromptBuilder.py | 14 +++++++++++++ promptsModules/model_manager.py | 1 + promptsModules/sd_command_gen.py | 2 +- scripts/prompt_rg.py | 31 +++++++++++++++++++---------- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/promptsModules/basePromptBuilder.py b/promptsModules/basePromptBuilder.py index e1ab2c3..43a88cc 100644 --- a/promptsModules/basePromptBuilder.py +++ b/promptsModules/basePromptBuilder.py @@ -247,6 +247,9 @@ body_desc_list = ["perfect body", "slim body", "perfect female body", "slender body", "soaked body", "steaming body"] +body_skin = ["shiny skin", "smooth skin", "soft skin", "glowing skin", "flawless skin", "porcelain skin", + "luminous skin"] + details = ["elaborate", "ornate", "intricate", "detailed", "fine", "refined", "complicated", "convoluted", "extensive", "exhaustive", "far-reaching", "informative", "in-depth", "thorough", "step-by-step", "exact", "precise", "exquisite", "lavish", @@ -680,6 +683,15 @@ def get_body_description_prompt(): return current_prompt +def get_body_skin_prompt(): + current_prompt = "" + if get_config_value_by_key("body_skin"): + current_prompt = current_prompt + get_standard_prompt(body_skin) + return current_prompt + else: + return current_prompt + + def get_accessories_mix_prompt(): random_times = 1 random_times = get_config_value_by_key("accessories_random_tims") @@ -839,6 +851,7 @@ def get_body_wear_prompt(): + get_bottom_wear_prompt(bottom_wear) body_wear_output = body_wear_output \ + + get_body_skin_prompt() \ + get_body_description_prompt() \ + get_legwear_prompt() \ + get_body_with_prompt() \ @@ -1313,6 +1326,7 @@ class NSFWType(IntEnum): "body_with": True, "body_status": True, "body_description": False, + "body_skin": False, "cloth_trim": True, # 颜色,只用给颜色即可 diff --git a/promptsModules/model_manager.py b/promptsModules/model_manager.py index aadc14b..240a62c 100644 --- a/promptsModules/model_manager.py +++ b/promptsModules/model_manager.py @@ -107,6 +107,7 @@ def loadData(self): def query_data(self, model_id): if self._lastModifyTime != os.path.getmtime(self.get_excel_file_path()): + print("prompt config changed, reloading....") self.reload() if model_id in self._data: return self._data[model_id] diff --git a/promptsModules/sd_command_gen.py b/promptsModules/sd_command_gen.py index a69fabb..3ee25ac 100644 --- a/promptsModules/sd_command_gen.py +++ b/promptsModules/sd_command_gen.py @@ -20,7 +20,7 @@ """ // adetailer prompt: , 1girl, smile, cute, 18yo, extremely detailed eyes and face, beautiful face, -, 1girl, smile, cute, 18yo, +, 1girl, (smile), cute, 18yo, """ project_config = { diff --git a/scripts/prompt_rg.py b/scripts/prompt_rg.py index b83af01..2320ff7 100644 --- a/scripts/prompt_rg.py +++ b/scripts/prompt_rg.py @@ -3,9 +3,9 @@ import gradio as gr +from promptsModules.model_manager import (LoraConfigManager) from promptsModules.sd_command_gen import project_config as gen_config from promptsModules.web_api import (create_prompts) -from promptsModules.model_manager import (LoraConfigManager) project_config = gen_config t2i_text_box = None @@ -22,7 +22,8 @@ def get_model_input(com_value): ######### gen ######### # 我有史以来写的最长的方法 -def gen_action(gen_times, widget_lora, widget_lyco, widget_embeddings, model_order, additional_prompt, angle, body_framing, location, +def gen_action(gen_times, widget_lora, widget_lyco, widget_embeddings, model_order, additional_prompt, angle, + body_framing, location, pose_type, dynamic_mode, breasts_size, body_wear, top_wear, bottom_wear, leg_wear, panties, shoes_type, body_with, body_status, body_desc, cloth_trim, profession, hair_color, add_hair_style, enable_eye_color, @@ -32,7 +33,7 @@ def gen_action(gen_times, widget_lora, widget_lyco, widget_embeddings, model_ord object_random_times, suffix_words_random_times, assign_angle, assign_body_framing, assign_place, assign_pose, assign_job, assigin_expression, assign_clothes, assign_leg_wear, assign_shoes, assign_leg_wear_color, assign_shoes_color, assign_hair_color, hair_accessories, neck_accessories, - earrings, has_ending, hair_length, people_cnt): + earrings, has_ending, hair_length, people_cnt, body_skin): if angle: project_config["angle"] = "" else: @@ -69,6 +70,7 @@ def gen_action(gen_times, widget_lora, widget_lyco, widget_embeddings, model_ord project_config["body_with"] = body_with project_config["body_status"] = body_status project_config["body_description"] = body_desc + project_config["body_skin"] = body_skin project_config["cloth_trim"] = cloth_trim if profession: project_config["assign_profession"] = "" @@ -140,6 +142,8 @@ def send_action(result_text): top_ele = stripped_lines[0] top_ele = re.sub(r'\n+$', '', top_ele) return top_ele + else: + raise gr.Error("请安装到sd webui中使用此功能.") def load_config_action(): @@ -220,6 +224,7 @@ def on_ui_tabs(): hair_accessories = gr.Checkbox(True, label="头饰") neck_accessories = gr.Checkbox(True, label="颈部饰物") earrings = gr.Checkbox(True, label="耳环") + body_skin = gr.Checkbox(False, label="皮肤") with gr.Row(): face_expression = gr.Dropdown( ["情绪EMOTIONS", "诱惑的SEXUAL", "笑容SMILE", "俏皮的SMUG", "以上随机", "空NULL"], @@ -255,12 +260,15 @@ def on_ui_tabs(): with gr.Box(): with gr.Row(): widget_lora = gr.Textbox("", label="Lora【x】", - info="格式如下:101, 101:0.6, 路易斯:0.65", elem_id="rp_widget_lora") + info="格式如下:101, 101:0.6, 路易斯:0.65", + elem_id="rp_widget_lora") widget_lyco = gr.Textbox("", label="lyco【y】", - info="格式如下:101, 101:0.6, 添加细节:1", elem_id="rp_widget_lyco") + info="格式如下:101, 101:0.6, 添加细节:1", + elem_id="rp_widget_lyco") with gr.Row(): widget_embeddings = gr.Textbox("", label="embeddings【z】", - info="格式如下:100, ul:0.6", elem_id="rp_widget_embeddings") + info="格式如下:100, ul:0.6", + elem_id="rp_widget_embeddings") model_order = gr.Textbox("xyz", label="lora,lyco,embed顺序", info="默认为xyz顺序,即按照lora,lyco,emb顺序") with gr.Box(): @@ -311,7 +319,7 @@ def on_ui_tabs(): additional_prompt = gr.Textbox("", label="额外的prompt") with gr.Column(scale=1): gr.Markdown("prompt输出:") - results = gr.Textbox("", label="生成的prompt", lines=20, show_copy_button=True, interactive=False) + results = gr.Textbox("", label="生成的prompt", lines=20, show_copy_button=True, interactive=True) with gr.Row(): gen_button = gr.Button("生成prompt") send_button = gr.Button("发送到文生图") @@ -326,7 +334,8 @@ def on_ui_tabs(): review_btn.click(load_config_action, outputs=data_sheet) gen_button.click(gen_action, - inputs=[time_slider, widget_lora, widget_lyco, widget_embeddings, model_order, additional_prompt, angle, + inputs=[time_slider, widget_lora, widget_lyco, widget_embeddings, model_order, + additional_prompt, angle, body_framing, location, pose_type, dynamic_mode, breasts_size, body_wear, top_wear, bottom_wear, leg_wear, panties, shoes_type, body_with, body_status, body_desc, cloth_trim, profession, @@ -340,7 +349,7 @@ def on_ui_tabs(): assign_place, assign_pose, assign_job, assigin_expression, assign_clothes, assign_leg_wear, assign_shoes, assign_leg_wear_color, assign_shoes_color, assign_hair_color, hair_accessories, neck_accessories, earrings, has_ending, - hair_length, people_cnt], outputs=results) + hair_length, people_cnt, body_skin], outputs=results) send_button.click(send_action, inputs=results, outputs=t2i_text_box) if IS_PLUGIN: return [(ui_component, "随机提示词RP", "随机提示词RP")] @@ -362,4 +371,6 @@ def after_component(component, **kwargs): script_module.on_after_component(after_component) else: - on_ui_tabs().launch(debug=True) + app = on_ui_tabs() + app.queue(max_size=10) + app.launch(debug=True)