mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
jumbo merge part three
This commit is contained in:
Vendored
+3
-1
@@ -68,7 +68,9 @@ window.document.addEventListener('drop', (e) => {
|
||||
window.addEventListener('paste', (e) => {
|
||||
const { files } = e.clipboardData;
|
||||
if (!isValidImageList(files)) return;
|
||||
const visibleImageFields = [...gradioApp().querySelectorAll('[data-testid="image"]')].filter((el) => uiElementIsVisible(el));
|
||||
const visibleImageFields = [...gradioApp().querySelectorAll('[data-testid="image"]')]
|
||||
.filter((el) => uiElementIsVisible(el))
|
||||
.sort((a, b) => uiElementInSight(b) - uiElementInSight(a));
|
||||
if (!visibleImageFields.length) return;
|
||||
const firstFreeImageField = visibleImageFields.filter((el) => el.querySelector('input[type=file]'))?.[0];
|
||||
dropReplaceImage(firstFreeImageField || visibleImageFields[visibleImageFields.length - 1], files);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
function keyupEditAttention(event) {
|
||||
const target = event.originalTarget || event.composedPath()[0];
|
||||
if (!target.matches("[id*='_toprow'] [id*='_prompt'] textarea")) return;
|
||||
if (!target.matches("*:is([id*='_toprow'] [id*='_prompt'], .prompt) textarea")) return;
|
||||
if (!(event.metaKey || event.ctrlKey)) return;
|
||||
const isPlus = event.key === 'ArrowUp';
|
||||
const isMinus = event.key === 'ArrowDown';
|
||||
|
||||
@@ -3,7 +3,7 @@ function start_training_textual_inversion() {
|
||||
var id = randomId()
|
||||
const onProgress = (progress) => gradioApp().getElementById('ti_progress').innerHTML = progress.textinfo;
|
||||
requestProgress(id, gradioApp().getElementById('ti_gallery'), null, onProgress, false)
|
||||
var res = args_to_array(arguments)
|
||||
var res = Array.from(arguments);
|
||||
res[0] = id
|
||||
return res
|
||||
}
|
||||
|
||||
+13
-19
@@ -41,15 +41,11 @@ function extract_image_from_gallery(gallery) {
|
||||
return [gallery[index]];
|
||||
}
|
||||
|
||||
function args_to_array(args) {
|
||||
const res = [];
|
||||
for (let i = 0; i < args.length; i++) res.push(args[i]);
|
||||
return res;
|
||||
}
|
||||
window.args_to_array = Array.from; // Compatibility with e.g. extensions that may expect this to be around
|
||||
|
||||
function switch_to_txt2img(...args) {
|
||||
gradioApp().querySelector('#tabs').querySelectorAll('button')[0].click();
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function switch_to_img2img_tab(no) {
|
||||
@@ -59,27 +55,27 @@ function switch_to_img2img_tab(no) {
|
||||
|
||||
function switch_to_img2img(...args) {
|
||||
switch_to_img2img_tab(0);
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function switch_to_sketch(...args) {
|
||||
switch_to_img2img_tab(1);
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function switch_to_inpaint(...args) {
|
||||
switch_to_img2img_tab(2);
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function switch_to_inpaint_sketch(...args) {
|
||||
switch_to_img2img_tab(3);
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function switch_to_extras(...args) {
|
||||
gradioApp().querySelector('#tabs').querySelectorAll('button')[2].click();
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function get_tab_index(tabId) {
|
||||
@@ -92,22 +88,20 @@ function get_tab_index(tabId) {
|
||||
}
|
||||
|
||||
function create_tab_index_args(tabId, args) {
|
||||
const res = [];
|
||||
for (let i = 0; i < args.length; i++) res.push(args[i]);
|
||||
let res = Array.from(args);
|
||||
res[0] = get_tab_index(tabId);
|
||||
return res;
|
||||
}
|
||||
|
||||
function get_img2img_tab_index(...args) {
|
||||
const res = args_to_array(args);
|
||||
let res = Array.from(arguments);
|
||||
res.splice(-2);
|
||||
res[0] = get_tab_index('mode_img2img');
|
||||
return res;
|
||||
}
|
||||
|
||||
function create_submit_args(args) {
|
||||
const res = [];
|
||||
for (let i = 0; i < args.length; i++) res.push(args[i]);
|
||||
var res = Array.from(args);
|
||||
// As it is currently, txt2img and img2img send back the previous output args (txt2img_gallery, generation_info, html_info) whenever you generate a new image.
|
||||
// This can lead to uploading a huge gallery of previously generated images, which leads to an unnecessary delay between submitting and beginning to generate.
|
||||
// I don't know why gradio is sending outputs along with inputs, but we can prevent sending the image gallery here, which seems to be an issue for some.
|
||||
@@ -168,19 +162,19 @@ function recalculatePromptTokens(name) {
|
||||
function recalculate_prompts_txt2img(...args) {
|
||||
recalculatePromptTokens('txt2img_prompt');
|
||||
recalculatePromptTokens('txt2img_neg_prompt');
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function recalculate_prompts_img2img(...args) {
|
||||
recalculatePromptTokens('img2img_prompt');
|
||||
recalculatePromptTokens('img2img_neg_prompt');
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function recalculate_prompts_inpaint(...args) {
|
||||
recalculatePromptTokens('img2img_prompt');
|
||||
recalculatePromptTokens('img2img_neg_prompt');
|
||||
return args_to_array(args);
|
||||
return Array.from(arguments);
|
||||
}
|
||||
|
||||
function register_drag_drop() {
|
||||
|
||||
Reference in New Issue
Block a user