From 504dd5876fb03ddbc406a22ee225166e13b8eaf8 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 5 Apr 2023 20:56:32 +0200 Subject: [PATCH] negative prompt --- matrix_pygmalion_bot/core.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/matrix_pygmalion_bot/core.py b/matrix_pygmalion_bot/core.py index 510fa8e..f39bc2c 100644 --- a/matrix_pygmalion_bot/core.py +++ b/matrix_pygmalion_bot/core.py @@ -83,7 +83,6 @@ class Callbacks(object): print(event) await self.bot.send_message(self.client, room.room_id, "Hello World!") return - elif re.search("^!image(?P[0-9])(\s(?P.*))?$", event.body): m = re.search("^!image(?P[0-9])?(\s(?P.*))?$", event.body) if m['num']: @@ -99,7 +98,9 @@ class Callbacks(object): prompt = self.bot.image_prompt else: prompt = "a beautiful woman" - if num == 1: + if self.bot.negative_prompt: + negative_prompt = self.bot.negative_prompt + elif num == 1: negative_prompt = "out of frame, (ugly:1.3), (fused fingers), (too many fingers), (bad anatomy:1.5), (watermark:1.5), (words), letters, untracked eyes, asymmetric eyes, floating head, (logo:1.5), (bad hands:1.3), (mangled hands:1.2), (missing hands), (missing arms), backward hands, floating jewelry, unattached jewelry, floating head, doubled head, unattached head, doubled head, head in body, (misshapen body:1.1), (badly fitted headwear:1.2), floating arms, (too many arms:1.5), limbs fused with body, (facial blemish:1.5), badly fitted clothes, imperfect eyes, untracked eyes, crossed eyes, hair growing from clothes, partial faces, hair not attached to head" elif num == 5: negative_prompt = "anime, cartoon, penis, fake, drawing, illustration, boring, 3d render, long neck, out of frame, extra fingers, mutated hands, monochrome, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), cloned face, glitchy, bokeh, (((long neck))), 3D, 3DCG, cgstation, red eyes, multiple subjects, extra heads, close up, watermarks, logo" @@ -144,6 +145,12 @@ class Callbacks(object): await self.bot.send_image(self.client, room.room_id, imagefile) return + elif event.body.startswith('!image_negative_prompt'): + negative_prompt = event.body.removeprefix('!image_negative_prompt').strip() + if len(prompt) > 0: + self.bot.negative_prompt = negative_prompt + else: + self.bot.negative_prompt = None elif event.body.startswith('!begin'): self.bot.chat_history.room(room.display_name).clear() self.bot.room_config[room.room_id]["tick"] = 0