Commit bb0f1a2c authored by yfszzx's avatar yfszzx

inspiration finished

parent dc665406
function public_image_index_in_gallery(item, gallery){ function public_image_index_in_gallery(item, gallery){
var imgs = gallery.querySelectorAll("img.h-full")
var index; var index;
var i = 0; var i = 0;
gallery.querySelectorAll("img").forEach(function(e){ imgs.forEach(function(e){
if (e == item) if (e == item)
index = i; index = i;
i += 1; i += 1;
}); });
var num = imgs.length / 2
index = (index < num) ? index : (index - num)
return index; return index;
} }
function inspiration_selected(name, types, name_list){ function inspiration_selected(name, name_list){
var btn = gradioApp().getElementById("inspiration_select_button") var btn = gradioApp().getElementById("inspiration_select_button")
return [gradioApp().getElementById("inspiration_select_button").getAttribute("img-index"), types]; return [gradioApp().getElementById("inspiration_select_button").getAttribute("img-index")];
}
function inspiration_click_get_button(){
gradioApp().getElementById("inspiration_get_button").click();
} }
var inspiration_image_click = function(){ var inspiration_image_click = function(){
var index = public_image_index_in_gallery(this, gradioApp().getElementById("inspiration_gallery")); var index = public_image_index_in_gallery(this, gradioApp().getElementById("inspiration_gallery"));
var btn = gradioApp().getElementById("inspiration_select_button") var btn = gradioApp().getElementById("inspiration_select_button");
btn.setAttribute("img-index", index) btn.setAttribute("img-index", index);
setTimeout(function(btn){btn.click();}, 10, btn) setTimeout(function(btn){btn.click();}, 10, btn);
} }
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
...@@ -28,10 +34,9 @@ document.addEventListener("DOMContentLoaded", function() { ...@@ -28,10 +34,9 @@ document.addEventListener("DOMContentLoaded", function() {
if (node) { if (node) {
node.style.display = "None"; //parentNode.removeChild(node) node.style.display = "None"; //parentNode.removeChild(node)
} }
gallery.querySelectorAll('img').forEach(function(e){ gallery.querySelectorAll('img').forEach(function(e){
e.onclick = inspiration_image_click e.onclick = inspiration_image_click
}) });
} }
......
This diff is collapsed.
...@@ -316,6 +316,12 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters" ...@@ -316,6 +316,12 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters"
'eta_noise_seed_delta': OptionInfo(0, "Eta noise seed delta", gr.Number, {"precision": 0}), 'eta_noise_seed_delta': OptionInfo(0, "Eta noise seed delta", gr.Number, {"precision": 0}),
})) }))
options_templates.update(options_section(('inspiration', "Inspiration"), {
"inspiration_dir": OptionInfo("inspiration", "Directory of inspiration", component_args=hide_dirs),
"inspiration_max_samples": OptionInfo(4, "Maximum number of samples, used to determine which folders to skip when continue running the create script", gr.Slider, {"minimum": 1, "maximum": 20, "step": 1}),
"inspiration_rows_num": OptionInfo(4, "Rows of inspiration interface frame", gr.Slider, {"minimum": 4, "maximum": 16, "step": 1}),
"inspiration_cols_num": OptionInfo(8, "Columns of inspiration interface frame", gr.Slider, {"minimum": 4, "maximum": 16, "step": 1}),
}))
class Options: class Options:
data = None data = None
......
...@@ -1180,7 +1180,7 @@ def create_ui(wrap_gradio_gpu_call): ...@@ -1180,7 +1180,7 @@ def create_ui(wrap_gradio_gpu_call):
} }
browser_interface = images_history.create_history_tabs(gr, opts, wrap_gradio_call(modules.extras.run_pnginfo), images_history_switch_dict) browser_interface = images_history.create_history_tabs(gr, opts, wrap_gradio_call(modules.extras.run_pnginfo), images_history_switch_dict)
inspiration_interface = inspiration.ui(gr, opts) inspiration_interface = inspiration.ui(gr, opts, txt2img_prompt, img2img_prompt)
with gr.Blocks() as modelmerger_interface: with gr.Blocks() as modelmerger_interface:
with gr.Row().style(equal_height=False): with gr.Row().style(equal_height=False):
......
...@@ -72,6 +72,7 @@ def wrap_gradio_gpu_call(func, extra_outputs=None): ...@@ -72,6 +72,7 @@ def wrap_gradio_gpu_call(func, extra_outputs=None):
return modules.ui.wrap_gradio_call(f, extra_outputs=extra_outputs) return modules.ui.wrap_gradio_call(f, extra_outputs=extra_outputs)
def initialize(): def initialize():
modules.scripts.load_scripts(os.path.join(script_path, "scripts"))
if cmd_opts.ui_debug_mode: if cmd_opts.ui_debug_mode:
class enmpty(): class enmpty():
name = None name = None
...@@ -84,7 +85,7 @@ def initialize(): ...@@ -84,7 +85,7 @@ def initialize():
shared.face_restorers.append(modules.face_restoration.FaceRestoration()) shared.face_restorers.append(modules.face_restoration.FaceRestoration())
modelloader.load_upscalers() modelloader.load_upscalers()
modules.scripts.load_scripts(os.path.join(script_path, "scripts"))
shared.sd_model = modules.sd_models.load_model() shared.sd_model = modules.sd_models.load_model()
shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(shared.sd_model))) shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(shared.sd_model)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment