Update PNG_info_web.js
Browse files- PNG_info_web.js +54 -12
PNG_info_web.js
CHANGED
|
@@ -306,10 +306,12 @@
|
|
| 306 |
}
|
| 307 |
|
| 308 |
|
|
|
|
| 309 |
setTimeout(()=>{
|
|
|
|
| 310 |
const elem = document.querySelector('gradio-app');
|
| 311 |
-
const shadowRoot = elem
|
| 312 |
-
const png_info = shadowRoot.querySelector('#pnginfo_image
|
| 313 |
png_info.addEventListener('change', (e) => {
|
| 314 |
// 获取用户选择的文件
|
| 315 |
// const file = png_info.files[0];
|
|
@@ -319,8 +321,8 @@
|
|
| 319 |
console.log(png_info_img_convert)
|
| 320 |
let res=await readNovelAITag(png_info_img_convert)
|
| 321 |
console.log('res',res)
|
| 322 |
-
shadowRoot.querySelector('#component-
|
| 323 |
-
|
| 324 |
//js对象形式转化
|
| 325 |
const result = {};
|
| 326 |
// const match = inputString.match(/(?<=prompt:)(.*)(?=Negative prompt:)/s)[0].trim();]
|
|
@@ -334,34 +336,74 @@
|
|
| 334 |
})
|
| 335 |
console.log(result)
|
| 336 |
console.log('result',result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
shadowRoot.querySelector('#txt2img_tab').onclick=()=>{
|
| 338 |
-
shadowRoot.querySelector('[class="
|
| 339 |
-
|
| 340 |
shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[0].value=Number(result.Clipskip)
|
|
|
|
|
|
|
| 341 |
shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[1].value=Number(result.Clipskip)
|
|
|
|
|
|
|
| 342 |
shadowRoot.querySelector('#txt2img_prompt textarea').value=result.prompt
|
|
|
|
|
|
|
| 343 |
shadowRoot.querySelector('#txt2img_neg_prompt textarea').value=result.negativePrompt
|
|
|
|
|
|
|
| 344 |
shadowRoot.querySelectorAll('#txt2img_steps input')[0].value=Number(result.Steps)
|
|
|
|
|
|
|
| 345 |
shadowRoot.querySelectorAll('#txt2img_steps input')[1].value=Number(result.Steps)
|
| 346 |
-
shadowRoot.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
shadowRoot.querySelectorAll('#txt2img_width input')[0].value=Number(result.Size.split('x')[0])
|
|
|
|
|
|
|
| 348 |
shadowRoot.querySelectorAll('#txt2img_width input')[1].value=Number(result.Size.split('x')[0])
|
|
|
|
|
|
|
| 349 |
shadowRoot.querySelectorAll('#txt2img_height input')[0].value=Number(result.Size.split('x')[1])
|
|
|
|
|
|
|
| 350 |
shadowRoot.querySelectorAll('#txt2img_height input')[1].value=Number(result.Size.split('x')[1])
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
// shadowRoot.querySelectorAll('#txt2img_batch_size input')[0].value=3
|
| 354 |
-
// shadowRoot.querySelectorAll('#txt2img_batch_size input')[1].value=3
|
| 355 |
shadowRoot.querySelector('#txt2img_seed input').value=Number(result.Seed)
|
|
|
|
|
|
|
| 356 |
//高清修复
|
| 357 |
shadowRoot.querySelector('#txt2img_enable_hr input').checked = !!result.Hiresupscaler
|
| 358 |
-
shadowRoot.
|
|
|
|
|
|
|
|
|
|
| 359 |
shadowRoot.querySelectorAll('#txt2img_hires_steps input')[0].value=Number(result.Hiressteps)||0
|
|
|
|
|
|
|
| 360 |
shadowRoot.querySelectorAll('#txt2img_hires_steps input')[1].value=Number(result.Hiressteps)||0
|
|
|
|
|
|
|
| 361 |
shadowRoot.querySelectorAll('#txt2img_denoising_strength input')[0].value=Number(result.Denoisingstrength)||0
|
|
|
|
|
|
|
| 362 |
shadowRoot.querySelectorAll('#txt2img_denoising_strength input')[1].value=Number(result.Denoisingstrength)||0
|
|
|
|
|
|
|
| 363 |
shadowRoot.querySelectorAll('#txt2img_hr_scale input')[0].value=Number(result.Hiresupscale)||1
|
|
|
|
|
|
|
| 364 |
shadowRoot.querySelectorAll('#txt2img_hr_scale input')[1].value=Number(result.Hiresupscale)||1
|
|
|
|
|
|
|
| 365 |
}
|
| 366 |
},100)
|
| 367 |
});
|
|
|
|
| 306 |
}
|
| 307 |
|
| 308 |
|
| 309 |
+
|
| 310 |
setTimeout(()=>{
|
| 311 |
+
console.log(123)
|
| 312 |
const elem = document.querySelector('gradio-app');
|
| 313 |
+
const shadowRoot = elem
|
| 314 |
+
const png_info = shadowRoot.querySelector('#pnginfo_image');
|
| 315 |
png_info.addEventListener('change', (e) => {
|
| 316 |
// 获取用户选择的文件
|
| 317 |
// const file = png_info.files[0];
|
|
|
|
| 321 |
console.log(png_info_img_convert)
|
| 322 |
let res=await readNovelAITag(png_info_img_convert)
|
| 323 |
console.log('res',res)
|
| 324 |
+
shadowRoot.querySelector('#component-677').innerText=res.length?res[0].text:'这不是一张stablediffusion图片'
|
| 325 |
+
|
| 326 |
//js对象形式转化
|
| 327 |
const result = {};
|
| 328 |
// const match = inputString.match(/(?<=prompt:)(.*)(?=Negative prompt:)/s)[0].trim();]
|
|
|
|
| 336 |
})
|
| 337 |
console.log(result)
|
| 338 |
console.log('result',result)
|
| 339 |
+
|
| 340 |
+
const inputEvent = new Event('input');
|
| 341 |
+
const changeEvent = new Event('change');
|
| 342 |
+
|
| 343 |
+
|
| 344 |
shadowRoot.querySelector('#txt2img_tab').onclick=()=>{
|
| 345 |
+
shadowRoot.querySelector('[class="tab-nav scroll-hide svelte-1g805jl"]').children[0].click()
|
| 346 |
+
|
| 347 |
shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[0].value=Number(result.Clipskip)
|
| 348 |
+
shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[0].dispatchEvent(inputEvent);
|
| 349 |
+
|
| 350 |
shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[1].value=Number(result.Clipskip)
|
| 351 |
+
shadowRoot.querySelectorAll('#setting_CLIP_stop_at_last_layers input')[1].dispatchEvent(inputEvent);
|
| 352 |
+
|
| 353 |
shadowRoot.querySelector('#txt2img_prompt textarea').value=result.prompt
|
| 354 |
+
shadowRoot.querySelector('#txt2img_prompt textarea').dispatchEvent(inputEvent);
|
| 355 |
+
|
| 356 |
shadowRoot.querySelector('#txt2img_neg_prompt textarea').value=result.negativePrompt
|
| 357 |
+
shadowRoot.querySelector('#txt2img_neg_prompt textarea').dispatchEvent(inputEvent);
|
| 358 |
+
|
| 359 |
shadowRoot.querySelectorAll('#txt2img_steps input')[0].value=Number(result.Steps)
|
| 360 |
+
shadowRoot.querySelectorAll('#txt2img_steps input')[0].dispatchEvent(inputEvent);
|
| 361 |
+
|
| 362 |
shadowRoot.querySelectorAll('#txt2img_steps input')[1].value=Number(result.Steps)
|
| 363 |
+
shadowRoot.querySelectorAll('#txt2img_steps input')[1].dispatchEvent(inputEvent);
|
| 364 |
+
|
| 365 |
+
shadowRoot.querySelector(`[value="${result.Sampler}"]`).checked = true;
|
| 366 |
+
shadowRoot.querySelector(`[value="${result.Sampler}"]`).dispatchEvent(changeEvent);
|
| 367 |
+
|
| 368 |
shadowRoot.querySelectorAll('#txt2img_width input')[0].value=Number(result.Size.split('x')[0])
|
| 369 |
+
shadowRoot.querySelectorAll('#txt2img_width input')[0].dispatchEvent(inputEvent);
|
| 370 |
+
|
| 371 |
shadowRoot.querySelectorAll('#txt2img_width input')[1].value=Number(result.Size.split('x')[0])
|
| 372 |
+
shadowRoot.querySelectorAll('#txt2img_width input')[1].dispatchEvent(inputEvent);
|
| 373 |
+
|
| 374 |
shadowRoot.querySelectorAll('#txt2img_height input')[0].value=Number(result.Size.split('x')[1])
|
| 375 |
+
shadowRoot.querySelectorAll('#txt2img_height input')[0].dispatchEvent(inputEvent);
|
| 376 |
+
|
| 377 |
shadowRoot.querySelectorAll('#txt2img_height input')[1].value=Number(result.Size.split('x')[1])
|
| 378 |
+
shadowRoot.querySelectorAll('#txt2img_height input')[1].dispatchEvent(inputEvent);
|
| 379 |
+
|
|
|
|
|
|
|
| 380 |
shadowRoot.querySelector('#txt2img_seed input').value=Number(result.Seed)
|
| 381 |
+
shadowRoot.querySelector('#txt2img_seed input').dispatchEvent(inputEvent);
|
| 382 |
+
|
| 383 |
//高清修复
|
| 384 |
shadowRoot.querySelector('#txt2img_enable_hr input').checked = !!result.Hiresupscaler
|
| 385 |
+
shadowRoot.querySelectorAll('#txt2img_steps input')[1].dispatchEvent(changeEvent);
|
| 386 |
+
|
| 387 |
+
shadowRoot.querySelector('#txt2img_hr_upscaler .single-select').innerText = result.Hiresupscaler||'Latent'
|
| 388 |
+
|
| 389 |
shadowRoot.querySelectorAll('#txt2img_hires_steps input')[0].value=Number(result.Hiressteps)||0
|
| 390 |
+
shadowRoot.querySelectorAll('#txt2img_hires_steps input')[0].dispatchEvent(inputEvent);
|
| 391 |
+
|
| 392 |
shadowRoot.querySelectorAll('#txt2img_hires_steps input')[1].value=Number(result.Hiressteps)||0
|
| 393 |
+
shadowRoot.querySelectorAll('#txt2img_hires_steps input')[1].dispatchEvent(inputEvent);
|
| 394 |
+
|
| 395 |
shadowRoot.querySelectorAll('#txt2img_denoising_strength input')[0].value=Number(result.Denoisingstrength)||0
|
| 396 |
+
shadowRoot.querySelectorAll('#txt2img_denoising_strength input')[0].dispatchEvent(inputEvent);
|
| 397 |
+
|
| 398 |
shadowRoot.querySelectorAll('#txt2img_denoising_strength input')[1].value=Number(result.Denoisingstrength)||0
|
| 399 |
+
shadowRoot.querySelectorAll('#txt2img_denoising_strength input')[1].dispatchEvent(inputEvent);
|
| 400 |
+
|
| 401 |
shadowRoot.querySelectorAll('#txt2img_hr_scale input')[0].value=Number(result.Hiresupscale)||1
|
| 402 |
+
shadowRoot.querySelectorAll('#txt2img_hr_scale input')[0].dispatchEvent(inputEvent);
|
| 403 |
+
|
| 404 |
shadowRoot.querySelectorAll('#txt2img_hr_scale input')[1].value=Number(result.Hiresupscale)||1
|
| 405 |
+
shadowRoot.querySelectorAll('#txt2img_hr_scale input')[1].dispatchEvent(inputEvent);
|
| 406 |
+
|
| 407 |
}
|
| 408 |
},100)
|
| 409 |
});
|