From 48dd451a8cf3dfadb2c6df65837f4fde4b07973a Mon Sep 17 00:00:00 2001 From: Llama <34464159+pi6am@users.noreply.github.com> Date: Sun, 1 Jan 2023 21:12:25 -0800 Subject: [PATCH] Add the ability to insert the story prompt into the art guide. The art guide now optionally supports the sequence <|> If this exists in the art guide, <|> is replaced by the story summary. Otherwise, the art guide is appended to the summary as before. Update the default art guide to place the medium before the summary. Also update the art guide tooltip to include the new default. --- aiserver.py | 18 +++++++++++++----- gensettings.py | 2 +- koboldai_settings.py | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/aiserver.py b/aiserver.py index bb79fe99..814d8f8c 100644 --- a/aiserver.py +++ b/aiserver.py @@ -9492,7 +9492,7 @@ def UI_2_generate_image_from_story(data): koboldai_vars.generating_image = True eventlet.sleep(0) - art_guide = '{}'.format(koboldai_vars.img_gen_art_guide) + art_guide = str(koboldai_vars.img_gen_art_guide) if 'action_id' in data and (int(data['action_id']) in koboldai_vars.actions.actions or int(data['action_id']) == -1): action_id = int(data['action_id']) @@ -9526,13 +9526,21 @@ def UI_2_generate_image_from_story(data): max_length = args.max_summary_length - len(koboldai_vars.summary_tokenizer.encode(art_guide)) keys = [summarize(text, max_length=max_length)] - logger.debug("Text from summarizer: {}".format(keys[0])) - prompt = ", ".join(keys) + logger.debug("Text from summarizer: {}".format(prompt)) + + if art_guide: + if '<|>' in art_guide: + full_prompt = art_guide.replace('<|>', prompt) + else: + full_prompt = f"{prompt}, {art_guide}" + else: + full_prompt = prompt + generate_story_image( - ", ".join([part for part in [prompt, art_guide] if part]), + full_prompt, file_prefix=f"action_{action_id}", - display_prompt=prompt, + display_prompt=full_prompt, log_data={"actionId": action_id}, ) diff --git a/gensettings.py b/gensettings.py index 1e6f94fa..214d2f45 100644 --- a/gensettings.py +++ b/gensettings.py @@ -613,7 +613,7 @@ gensettingstf = [ "label": "Art Guide", "id": "img_gen_art_guide", "default": "", - "tooltip": "The art guide sent with image gen requests. \nDefault: fantasy illustration, artstation, by jason felix by steve argyle by tyler jacobson by peter mohrbacher, cinematic lighting", + "tooltip": "The art guide sent with image gen requests. <|> (optional) is replaced with the story summary, otherwise the art guide is appended to the summary. \nDefault: masterpiece, digital painting, <|>, dramatic lighting, highly detailed, trending", "menu_path": "Interface", "sub_path": "Images", "classname": "user", diff --git a/koboldai_settings.py b/koboldai_settings.py index a0588572..45281e3f 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1159,7 +1159,7 @@ class user_settings(settings): self.show_budget = False self.ui_level = 2 self.img_gen_api_url = "http://127.0.0.1:7860" - self.img_gen_art_guide = "digital painting, dramatic lighting, highly detailed, trending" + self.img_gen_art_guide = "masterpiece, digital painting, <|>, dramatic lighting, highly detailed, trending" self.img_gen_negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name" self.img_gen_steps = 30 self.img_gen_cfg_scale = 7.0