diff --git a/src/GenerateTab.vue b/src/GenerateTab.vue index e38e629..a04e6eb 100644 --- a/src/GenerateTab.vue +++ b/src/GenerateTab.vue @@ -197,6 +197,51 @@ +
+ ControlNet mode + + + {{ cnM }} + +
+ + + + Weight + {{ cnWeight/100 }} + + + + + + Guidance start + {{ cnGuidanceStart/100 }} + + + + + + Guidance end + {{ cnGuidanceEnd/100 }} + + +
Save generated images locally @@ -287,6 +332,28 @@ export default { imagesNumber: 4, styles: [], + cnModes: ['disabled', 'tile', 'openface', 'openpose', 'lineart', 'scribble'], + cnMode: 'disabled', + cnWeight: 100, + cnGuidanceStart: 0, + cnGuidanceEnd: 100, + cnModules: { + disabled: undefined, + tile: undefined, + lineart: 'lineart_coarse', + openpose: 'openpose_full', + openface: 'openpose_faceonly', + scribble: 'pidinet_sketch', + }, + cnModels: { + disabled: undefined, + tile: 'control_v11f1e_sd15_tile_fp16', + lineart: 'control_v11p_sd15_lineart_fp16', + openpose: 'control_v11p_sd15_openpose_fp16', + openface: 'control_v11p_sd15_openpose_fp16', + scribble: 'control_v11p_sd15_scribble_fp16', + }, + generatedImages: [], currentGeneratedImageIndex: 0, currentLayerId: null, @@ -398,7 +465,11 @@ export default { this.currentSampler = storage.localStorage.getItem('currentSampler') || this.currentSampler; this.imagesNumber = storage.localStorage.getItem('imagesNumber') || this.imagesNumber; this.currentMode = storage.localStorage.getItem('currentMode') || this.currentMode; + this.denoisingStrength = storage.localStorage.getItem('denoisingStrength') || this.denoisingStrength; this.isSaveImagesLocally = storage.localStorage.getItem('isSaveImagesLocally') || this.isSaveImagesLocally; + this.cnWeight = storage.localStorage.getItem('cnWeight') || this.cnWeight; + this.cnGuidanceStart = storage.localStorage.getItem('cnGuidanceStart') || this.cnGuidanceStart; + this.cnGuidanceEnd = storage.localStorage.getItem('cnGuidanceEnd') || this.cnGuidanceEnd; this.getTempAndDataFolders(); @@ -596,6 +667,11 @@ export default { } let resDataImages = res.data.images; + + // if (this.cnMode !== 'disabled') { + // resDataImages.pop(); // last image is controlNet input image + // } + if (this.isSaveImagesLocally) { await this.saveGeneratedImagesLocally(resDataImages, JSON.parse(res.data.info).all_seeds); } diff --git a/src/maskGeneratorMixin.js b/src/maskGeneratorMixin.js index 3112eea..a11bc41 100644 --- a/src/maskGeneratorMixin.js +++ b/src/maskGeneratorMixin.js @@ -139,6 +139,10 @@ export default { storage.localStorage.setItem('currentSampler', this.currentSampler); storage.localStorage.setItem('imagesNumber', this.imagesNumber); storage.localStorage.setItem('currentMode', this.currentMode); + storage.localStorage.setItem('denoisingStrength', this.denoisingStrength); + storage.localStorage.setItem('cnWeight', this.cnWeight); + storage.localStorage.setItem('cnGuidanceStart', this.cnGuidanceStart); + storage.localStorage.setItem('cnGuidanceEnd', this.cnGuidanceEnd); this.updateProgress(); @@ -180,8 +184,28 @@ export default { override_settings: {}, sampler_index: this.currentSampler, include_init_images: false, + alwayson_scripts: {}, }; + if (this.imagesNumber > 1 && img2imgData.prompt === '') { + img2imgData.prompt = 'prompt'; // fake prompt to avoid batch crash + } + + if (this.cnMode !== 'disabled') { + img2imgData.alwayson_scripts.controlnet = { + args: [ + { + weight: this.cnWeight / 100, + guidance_start: this.cnGuidanceStart / 100, + guidance_end: this.cnGuidanceEnd / 100, + module: this.cnModules[this.cnMode], + pixel_perfect: true, + model: this.cnModels[this.cnMode], + }, + ], + }; + } + await this.sendData(img2imgData, 'img2img'); }