From 89b6f0293648b11898aa764a39cf0465c70e0748 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Fri, 1 Sep 2023 17:49:40 -0400 Subject: [PATCH] Add options for AI prompt generation in Custom Images Only mode. --- js/003-data/gameVariableData.js | 1 + src/art/genAI/stableDiffusion.js | 2 +- src/gui/options/options.js | 59 +++++++++++++++++++------------- src/interaction/siCustom.js | 4 +-- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index f6eb669777e..6d74e63ebe8 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -173,6 +173,7 @@ App.Data.defaultGameStateVariables = { // Stable Diffusion settings aiApiUrl: "http://localhost:7860", aiCfgScale: 5, + aiCustomImagePrompts: 0, aiCustomStyleNeg: "", aiCustomStylePos: "", aiHeight: 768, diff --git a/src/art/genAI/stableDiffusion.js b/src/art/genAI/stableDiffusion.js index 60bdb4d57ca..ad687116056 100644 --- a/src/art/genAI/stableDiffusion.js +++ b/src/art/genAI/stableDiffusion.js @@ -193,7 +193,7 @@ App.Art.GenAI.sdQueue = new App.Art.GenAI.StableDiffusionClientQueue(); App.Art.GenAI.StableDiffusionClient = class { /** * @param {FC.SlaveState} slave - * @returns {App.Art.GenAI.StableDiffusionSettings} + * @returns {InstanceType<App.Art.GenAI.StableDiffusionSettings>} */ buildStableDiffusionSettings(slave) { const prompt = buildPrompt(slave); diff --git a/src/gui/options/options.js b/src/gui/options/options.js index 14a2432bf83..25c85674de2 100644 --- a/src/gui/options/options.js +++ b/src/gui/options/options.js @@ -1119,6 +1119,28 @@ App.Intro.contentAndFlavor = function(isIntro) { return el; }; +/** + * @param {InstanceType<App.UI.OptionsGroup>} options + */ +App.UI.aiPromptingOptions = function(options) { + options.addOption("AI style prompting", "aiStyle") + .addValueList([ + ["Photorealistic", 1], + ["Anime/Hentai", 2], + ["Custom", 0] + ]); + if (V.aiStyle === 0) { + options.addOption("AI custom style positive prompt", "aiCustomStylePos").showTextBox({large: true, forceString: true}) + .addComment("Include desired LoRA triggers (<code><lora:LowRA:0.5></code>) and general style prompts relevant to your chosen model ('<code>hand drawn, dark theme, black background</code>'), but no slave-specific prompts"); + options.addOption("AI custom style negative prompt", "aiCustomStyleNeg").showTextBox({large: true, forceString: true}) + .addComment("Include undesired general style prompts relevant to your chosen model ('<code>greyscale, photography, forest, low camera angle</code>'), but no slave-specific prompts"); + } else if (V.aiStyle === 1) { + options.addComment("For best results, use an appropriately-trained photorealistic base model, such as MajicMIX or Life Like Diffusion."); + } else if (V.aiStyle === 2) { + options.addComment("For best results, use an appropriately-trained hentai base model, such as Hassaku."); + } +}; + App.UI.artOptions = function() { const el = new DocumentFragment(); let options = new App.UI.OptionsGroup(); @@ -1236,22 +1258,7 @@ App.UI.artOptions = function() { options.addComment("This is highly experimental. Please follow the setup instructions below."); options.addCustom(App.UI.DOM.stableDiffusionInstallationGuide("Stable Diffusion Installation Guide")); options.addOption("API URL", "aiApiUrl").showTextBox().addComment("The URL of the Automatic 1111 Stable Diffusion API."); - options.addOption("AI style prompting", "aiStyle") - .addValueList([ - ["Photorealistic", 1], - ["Anime/Hentai", 2], - ["Custom", 0] - ]); - if (V.aiStyle === 0) { - options.addOption("AI custom style positive prompt", "aiCustomStylePos").showTextBox({large: true, forceString: true}) - .addComment("Include desired LoRA triggers (<code><lora:LowRA:0.5></code>) and general style prompts relevant to your chosen model ('<code>hand drawn, dark theme, black background</code>'), but no slave-specific prompts"); - options.addOption("AI custom style negative prompt", "aiCustomStyleNeg").showTextBox({large: true, forceString: true}) - .addComment("Include undesired general style prompts relevant to your chosen model ('<code>greyscale, photography, forest, low camera angle</code>'), but no slave-specific prompts"); - } else if (V.aiStyle === 1) { - options.addComment("For best results, use an appropriately-trained photorealistic base model, such as MajicMIX or Life Like Diffusion."); - } else if (V.aiStyle === 2) { - options.addComment("For best results, use an appropriately-trained hentai base model, such as Hassaku."); - } + App.UI.aiPromptingOptions(options); options.addOption("Sampling Method", "aiSamplingMethod").showTextBox() .addComment(`The sampling method used by AI. You can query ${V.aiApiUrl}/sdapi/v1/samplers to see the list of available samplers.`); options.addOption("CFG Scale", "aiCfgScale").showTextBox() @@ -1299,16 +1306,22 @@ App.UI.artOptions = function() { $("#cacheCount").empty().append(result.toString()); }); } - - options.addOption("PA avatar art is", "seeAvatar") + } else { // custom images only + options.addOption("Show suggested AI prompts in Customize tab", "aiCustomImagePrompts") .addValue("Enabled", 1).on().addValue("Disabled", 0).off(); + if (V.aiCustomImagePrompts) { + App.UI.aiPromptingOptions(options); + } + } - options.addOption("Slave images in lists are", "seeSummaryImages") - .addValue("Enabled", 1).on().addValue("Disabled", 0).off(); + options.addOption("PA avatar art is", "seeAvatar") + .addValue("Enabled", 1).on().addValue("Disabled", 0).off(); - options.addOption("Slave images in the weekly report are", "seeReportImages") - .addValue("Enabled", 1).on().addValue("Disabled", 0).off(); - } + options.addOption("Slave images in lists are", "seeSummaryImages") + .addValue("Enabled", 1).on().addValue("Disabled", 0).off(); + + options.addOption("Slave images in the weekly report are", "seeReportImages") + .addValue("Enabled", 1).on().addValue("Disabled", 0).off(); } el.append(options.render()); diff --git a/src/interaction/siCustom.js b/src/interaction/siCustom.js index 7548fc2f684..510adf0cee4 100644 --- a/src/interaction/siCustom.js +++ b/src/interaction/siCustom.js @@ -708,8 +708,8 @@ App.UI.SlaveInteract.custom = function(slave, refresh) { )); } - // Debug information for AI art - if (V.imageChoice === 6 && V.debugMode === 1) { + // Debug information for AI art, or prompt suggestions for custom images + if ((V.imageChoice === 6 && V.debugMode === 1) || (V.seeCustomImagesOnly && V.aiCustomImagePrompts)) { frag.append(genAIPrompt()); } return frag; -- GitLab