mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
update extra networks
This commit is contained in:
Submodule extensions-builtin/sd-webui-controlnet updated: 30cc2ec84f...2785cbe61a
@@ -32,19 +32,19 @@ function setupExtraNetworksForTab(tabname) {
|
||||
if (rect.top > 0) {
|
||||
if (!en) return
|
||||
if (window.opts.extra_networks_card_cover == 'cover') {
|
||||
en.style.zIndex = 0;
|
||||
en.style.zIndex = 9999;
|
||||
en.style.position = 'absolute';
|
||||
en.style.right = 'unset';
|
||||
en.style.width = 'unset';
|
||||
el.style.height = document.body.offsetHeight - el.getBoundingClientRect().top + 'px';
|
||||
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = 'unset'
|
||||
} if (window.opts.extra_networks_card_cover == 'sidebar') {
|
||||
en.style.zIndex = 9999;
|
||||
en.style.zIndex = 0;
|
||||
en.style.position = 'absolute';
|
||||
en.style.right = '0';
|
||||
en.style.width = '38vw';
|
||||
en.style.width = window.opts.extra_networks_sidebar_width + 'vw';
|
||||
el.style.height = gradioApp().getElementById(`${tabname}_settings`).offsetHeight - 90 + 'px';
|
||||
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = '60vw'
|
||||
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = 100 - 2 - window.opts.extra_networks_sidebar_width + 'vw';
|
||||
} else {
|
||||
en.style.zIndex = 0;
|
||||
en.style.position = 'relative';
|
||||
@@ -156,7 +156,6 @@ function readCardDescription(event, tabname, filename, descript, extraPage, card
|
||||
const button = gradioApp().getElementById(`${tabname}_read_description`);
|
||||
textarea.value = filename;
|
||||
description.value = descript;
|
||||
console.log(textarea.value, description.value);
|
||||
updateInput(textarea);
|
||||
updateInput(description);
|
||||
button.click();
|
||||
|
||||
@@ -542,7 +542,7 @@ table.settings-value-table td{
|
||||
.extra-networks-page { display: flex }
|
||||
.extra-networks .custom-button { min-width: 60px; width: 100%; background: none; justify-content: left; padding: 2px 8px 2px 8px; box-shadow: none; }
|
||||
.extra-networks .custom-button:hover { background: var(--button-primary-background-fill) }
|
||||
.extra-network-cards { display: flex; flex-wrap: wrap; height: 50vh; overflow-y: scroll; overflow-x: hidden; scroll-snap-type: y mandatory; }
|
||||
.extra-network-cards { display: flex; flex-wrap: wrap; height: 50vh; overflow-y: scroll; overflow-x: hidden; scroll-snap-type: y mandatory; width: -webkit-fill-available; }
|
||||
.extra-network-cards .card { height: fit-content; margin: 0.5em; position: relative; scroll-snap-align: start; scroll-margin-top: 0; }
|
||||
.extra-network-cards .card .overlay { position: absolute; bottom: 0; padding: 0.2em; z-index: 10; width: 100%; background: none; }
|
||||
.extra-network-cards .card:hover .overlay { background: rgba(0, 0, 0, 0.40); }
|
||||
|
||||
@@ -522,6 +522,7 @@ options_templates.update(options_section(('upscaling', "Upscaling"), {
|
||||
|
||||
options_templates.update(options_section(('extra_networks', "Extra Networks"), {
|
||||
"extra_networks_card_cover": OptionInfo("inline", "UI position", gr.Radio, lambda: {"choices": ["cover", "inline", "sidebar"]}),
|
||||
"extra_networks_sidebar_width": OptionInfo(35, "UI sidebar width (%)", gr.Slider, {"minimum": 10, "maximum": 80, "step": 1}),
|
||||
"extra_networks_card_size": OptionInfo(200, "UI card size (px)", gr.Slider, {"minimum": 20, "maximum": 2000, "step": 1}),
|
||||
"extra_networks_card_square": OptionInfo(False, "UI disable variable aspect ratio"),
|
||||
"extra_networks_card_fit": OptionInfo("cover", "UI image contain method", gr.Radio, lambda: {"choices": ["contain", "cover", "fill"]}),
|
||||
|
||||
@@ -332,7 +332,7 @@ def refresh_extensions_list_from_data(search_text, sort_column):
|
||||
ext['sort_enabled'] = f"{'0' if ext['enabled'] else '1'}{'1' if ext['is_builtin'] else '0'}{'1' if ext['installed'] else '0'}{ext.get('updated', '2000-01-01T00:00')}"
|
||||
ext['sort_update'] = f"{'1' if update_available else '0'}{'1' if ext['installed'] else '0'}{ext.get('updated', '2000-01-01T00:00')}"
|
||||
timedelta = datetime.now() - datetime.fromisoformat(ext.get('created', '2000-01-01T00:00Z')[:-1])
|
||||
ext['sort_trending'] = round(stars / (timedelta.days + 1), 1)
|
||||
ext['sort_trending'] = round(stars / min(timedelta.days, 5), 1)
|
||||
tags = ext.get("tags", [])
|
||||
if not isinstance(tags, list):
|
||||
tags = tags.split(' ')
|
||||
|
||||
@@ -165,26 +165,29 @@ class ExtraNetworksPage:
|
||||
<button class='lg secondary gradio-button custom-button{" search-all" if subdir=="" else ""}' onclick='extraNetworksSearchButton("{tabname}_extra_tabs", event)'>
|
||||
{html.escape(subdir) if subdir!="" else "all"}
|
||||
</button><br>""" for subdir in subdirs])
|
||||
# try:
|
||||
self.items = list(self.list_items())
|
||||
self.create_xyz_grid()
|
||||
for item in self.items:
|
||||
self.metadata[item["name"]] = item.get("metadata", {})
|
||||
self.info[item["name"]] = self.find_info(item['filename'])
|
||||
items_html += self.create_html_for_item(item, tabname)
|
||||
if items_html == '':
|
||||
dirs = "".join([f"<li>{x}</li>" for x in self.allowed_directories_for_previews()])
|
||||
items_html = f'<div class="nocards">No models found: ${dirs}</div>'
|
||||
self_name_id = self.name.replace(" ", "_")
|
||||
res = f"""
|
||||
<div id='{tabname}_{self_name_id}_subdirs' class='extra-network-subdirs'>{subdirs_html}</div>
|
||||
<div id='{tabname}_{self_name_id}_cards' class='extra-network-cards'>{items_html}</div>
|
||||
"""
|
||||
threading.Thread(target=self.create_thumb).start()
|
||||
return res
|
||||
# except Exception as e:
|
||||
# shared.log.error(f'Extra networks page error: {e}')
|
||||
# return ''
|
||||
try:
|
||||
self.items = list(self.list_items())
|
||||
self.create_xyz_grid()
|
||||
for item in self.items:
|
||||
self.metadata[item["name"]] = item.get("metadata", {})
|
||||
self.info[item["name"]] = self.find_info(item['filename'])
|
||||
items_html += self.create_html_for_item(item, tabname)
|
||||
# if items_html == '':
|
||||
# dirs = "".join([f"<li>{x}</li>" for x in self.allowed_directories_for_previews()])
|
||||
# items_html = f'<div class="nocards">No models found: {dirs}</div>'
|
||||
self_name_id = self.name.replace(" ", "_")
|
||||
if len(subdirs_html) > 0 or len(items_html) > 0:
|
||||
res = f"""
|
||||
<div id='{tabname}_{self_name_id}_subdirs' class='extra-network-subdirs'>{subdirs_html}</div>
|
||||
<div id='{tabname}_{self_name_id}_cards' class='extra-network-cards'>{items_html}</div>
|
||||
"""
|
||||
else:
|
||||
return ''
|
||||
threading.Thread(target=self.create_thumb).start()
|
||||
return res
|
||||
except Exception as e:
|
||||
shared.log.error(f'Extra networks page error: {e}')
|
||||
return ''
|
||||
|
||||
def list_items(self):
|
||||
raise NotImplementedError
|
||||
@@ -305,10 +308,12 @@ def create_ui(container, button, tabname):
|
||||
ui.description_target_filename = gr.Textbox('Description save filename', elem_id=tabname+"_description_filename", visible=False)
|
||||
|
||||
for page in ui.stored_extra_pages:
|
||||
with gr.Tab(page.title, id=page.title.lower().replace(" ", "_"), elem_classes="extra-networks-tab"):
|
||||
page_elem = gr.HTML(page.create_html(ui.tabname), elem_id=tabname+page.name+"_extra_page", elem_classes="extra-networks-page")
|
||||
page_elem.change(fn=lambda: None, _js=f'() => refreshExtraNetworks("{tabname}")', inputs=[], outputs=[])
|
||||
ui.pages.append(page_elem)
|
||||
page_html = page.create_html(ui.tabname)
|
||||
if len(page_html) > 0:
|
||||
with gr.Tab(page.title, id=page.title.lower().replace(" ", "_"), elem_classes="extra-networks-tab"):
|
||||
page_elem = gr.HTML(page_html, elem_id=tabname+page.name+"_extra_page", elem_classes="extra-networks-page")
|
||||
page_elem.change(fn=lambda: None, _js=f'() => refreshExtraNetworks("{tabname}")', inputs=[], outputs=[])
|
||||
ui.pages.append(page_elem)
|
||||
|
||||
def toggle_visibility(is_visible):
|
||||
is_visible = not is_visible
|
||||
|
||||
Reference in New Issue
Block a user