jumbo merge part three

This commit is contained in:
Vladimir Mandic
2023-06-14 13:54:23 -04:00
parent 0ddf613b49
commit 9334b2f21c
15 changed files with 116 additions and 72 deletions
+13 -19
View File
@@ -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() {