fix bug: controlnet won't generate detection map when paired with script

dev_v1.2.5
Abdullah Alfaraj 2023-05-23 17:35:04 +03:00
parent 4f07cea4e5
commit 20c891cb92
5 changed files with 912 additions and 87 deletions

2
.gitignore vendored
View File

@ -30,5 +30,5 @@ original_mask.png
# comments when packaging: # comments when packaging:
ultimate_sd_upscaler/dist/*LICENSE.txt
ultimate_sd_upscaler/dist/*.bundle.js ultimate_sd_upscaler/dist/*.bundle.js

963
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@
"nodemon": "^2.0.22", "nodemon": "^2.0.22",
"prettier": "2.8.3", "prettier": "2.8.3",
"style-loader": "^3.3.2", "style-loader": "^3.3.2",
"terser-webpack-plugin": "^3.0.8",
"ts-loader": "^9.4.2", "ts-loader": "^9.4.2",
"typescript": "^5.0.4", "typescript": "^5.0.4",
"webpack": "^5.82.1", "webpack": "^5.82.1",
@ -40,10 +41,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"build": "cd ultimate_sd_upscaler && npx webpack --config webpack.config.js", "build": "cd ultimate_sd_upscaler && npx webpack --config webpack.config.js",
"watch": "cd ultimate_sd_upscaler && npx webpack --config webpack.config.js --watch"
"watch": "cd ultimate_sd_upscaler && npx webpack --config webpack.config.js --watch"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -54,4 +52,4 @@
"url": "https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/issues" "url": "https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/issues"
}, },
"homepage": "https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin#readme" "homepage": "https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin#readme"
} }

View File

@ -603,7 +603,12 @@ async function requestControlNetTxt2Img(plugin_settings) {
app.showAlert('you need to select a valid ControlNet Module') app.showAlert('you need to select a valid ControlNet Module')
throw 'you need to select a valid ControlNet Module' throw 'you need to select a valid ControlNet Module'
} }
if (!control_net_settings['controlnet_units'][index]['model'] && !control_net.getModuleDetail()[control_net_settings['controlnet_units'][index]['module']].model_free) { if (
!control_net_settings['controlnet_units'][index]['model'] &&
!control_net.getModuleDetail()[
control_net_settings['controlnet_units'][index]['module']
].model_free
) {
app.showAlert('you need to select a valid ControlNet Model') app.showAlert('you need to select a valid ControlNet Model')
throw 'you need to select a valid ControlNet Model' throw 'you need to select a valid ControlNet Model'
} }
@ -684,7 +689,12 @@ async function requestControlNetImg2Img(plugin_settings) {
app.showAlert('you need to select a valid ControlNet Module') app.showAlert('you need to select a valid ControlNet Module')
throw 'you need to select a valid ControlNet Module' throw 'you need to select a valid ControlNet Module'
} }
if (!control_net_settings['controlnet_units'][index]['model'] && !control_net.getModuleDetail()[control_net_settings['controlnet_units'][index]['module']].model_free) { if (
!control_net_settings['controlnet_units'][index]['model'] &&
!control_net.getModuleDetail()[
control_net_settings['controlnet_units'][index]['module']
].model_free
) {
app.showAlert('you need to select a valid ControlNet Model') app.showAlert('you need to select a valid ControlNet Model')
throw 'you need to select a valid ControlNet Model' throw 'you need to select a valid ControlNet Model'
} }
@ -709,6 +719,15 @@ async function requestControlNetImg2Img(plugin_settings) {
numOfImages - g_generation_session.last_settings.batch_size numOfImages - g_generation_session.last_settings.batch_size
if (numberOfAnnotations < 0) numberOfAnnotations = 0 if (numberOfAnnotations < 0) numberOfAnnotations = 0
// To fix a bug: when Ultimate SD Upscale is active and running, the detection maps wont be retrieved.
// So set its value to 0 to avoid the result images being loaded in the annotation map interface.
if (
scripts.script_store.is_active &&
scripts.script_store.selected_script_name !== 'None' &&
scripts.script_store.is_selected_script_available
) {
numberOfAnnotations = 0
}
const base64_mask = json['images'].slice(numOfImages - numberOfAnnotations) const base64_mask = json['images'].slice(numOfImages - numberOfAnnotations)
let mask_index = 0 let mask_index = 0

View File

@ -12,7 +12,8 @@ module.exports = {
filename: '[name].bundle.js', filename: '[name].bundle.js',
libraryTarget: 'commonjs2', libraryTarget: 'commonjs2',
}, },
mode: 'development', // mode: 'development',
mode: 'production',
devtool: 'inline-source-map', // won't work on XD due to lack of eval devtool: 'inline-source-map', // won't work on XD due to lack of eval
externals: { externals: {
uxp: 'commonjs2 uxp', uxp: 'commonjs2 uxp',