From 931b9128113eeb9a64375266686d0cf97189bf69 Mon Sep 17 00:00:00 2001 From: ebolam Date: Wed, 21 Sep 2022 13:15:04 -0400 Subject: [PATCH] Fix for image generation to go to horde if the stable diffusion model isn't downloaded --- aiserver.py | 4 ++-- static/koboldai.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/aiserver.py b/aiserver.py index 35e0aafb..86430f83 100644 --- a/aiserver.py +++ b/aiserver.py @@ -8396,7 +8396,7 @@ def generate_image_in_background(): #If we don't have a GPU, use horde if we're allowed to start_time = time.time() - if (not koboldai_vars.hascuda and koboldai_vars.img_gen_priority != 0) or koboldai_vars.img_gen_priority == 3: + if ((not koboldai_vars.hascuda or not os.path.exists("models/stable-diffusion-v1-4")) and koboldai_vars.img_gen_priority != 0) or koboldai_vars.img_gen_priority == 3: b64_data = text2img_horde(", ".join(keys), art_guide = art_guide) else: import psutil @@ -8426,7 +8426,7 @@ def text2img_local(prompt, art_guide="", filename="new.png"): import base64 from io import BytesIO if koboldai_vars.image_pipeline is None: - pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, cache="./stable-diffusion-v1-4").to("cuda") + pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, cache="models/stable-diffusion-v1-4").to("cuda") else: pipe = koboldai_vars.image_pipeline.to("cuda") logger.debug("time to load: {}".format(time.time() - start_time)) diff --git a/static/koboldai.js b/static/koboldai.js index ac3867ab..6fa4abbe 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2321,6 +2321,21 @@ function retry_from_here() { } } +function push_to_clipboard() { + navigator.permissions.query({name: "clipboard-write"}).then((result) => { + if (result.state === "granted" || result.state === "prompt") { + navigator.clipboard.writeText(getSelectionText()); + } + }); +} + +function push_from_clipboard(el = document.activeElement) { + const [start, end] = [el.selectionStart, el.selectionEnd]; + navigator.clipboard.readText().then( + (clipText) => el.setRangeText(clipText, start, end, 'select')); + +} + function getSelectionText() { var text = ""; var activeEl = document.activeElement;