mirror of
https://github.com/vladmandic/automatic
synced 2026-08-27 15:41:00 +02:00
cleanup performance tags
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Submodule extensions-builtin/sdnext-modernui updated: c682cdabd2...4b8d5f6778
@@ -49,6 +49,8 @@ class Timer:
|
||||
additions = [x for x in self.records.items() if x[1] >= min_time]
|
||||
if max_time > 0:
|
||||
additions = [x for x in additions if x[1] <= max_time]
|
||||
if not total:
|
||||
additions = [x for x in additions if x[0] != 'total']
|
||||
additions = sorted(additions, key=lambda x: x[1], reverse=True)
|
||||
if not additions:
|
||||
return res
|
||||
|
||||
@@ -342,7 +342,7 @@ def create_output_panel(tabname, preview=True, prompt=None, height=None, transfe
|
||||
html_info = gr.HTML(elem_id=f'html_info_{tabname}', elem_classes="infotext", visible=False) # contains raw infotext as returned by wrapped call
|
||||
html_info_formatted = gr.HTML(elem_id=f'html_info_formatted_{tabname}', elem_classes="infotext", visible=True) # contains html formatted infotext
|
||||
html_info.change(fn=infotext_to_html, inputs=[html_info], outputs=[html_info_formatted], show_progress='hidden')
|
||||
html_log = gr.HTML(elem_id=f'html_log_{tabname}')
|
||||
html_log = gr.HTML(elem_id=f'html_log_{tabname}', elem_classes=["hint"])
|
||||
generation_info = gr.Textbox(visible=False, elem_id=f'generation_info_{tabname}')
|
||||
generation_info_button = gr.Button(visible=False, elem_id=f"{tabname}_generation_info_button")
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ def return_stats(t: float | None = None):
|
||||
elapsed = time.perf_counter() - t
|
||||
elapsed_m = int(elapsed // 60)
|
||||
elapsed_s = elapsed % 60
|
||||
elapsed_text = f"Time: {elapsed_m}m {elapsed_s:.2f}s |" if elapsed_m > 0 else f"Time: {elapsed_s:.2f}s |"
|
||||
elapsed_text = f"⏱ {elapsed_m}m {elapsed_s:.2f}s |" if elapsed_m > 0 else f"⏱ {elapsed_s:.2f}s |"
|
||||
summary = timer.process.summary(total=False).replace('=', ' ')
|
||||
gpu = ''
|
||||
cpu = ''
|
||||
@@ -34,18 +34,18 @@ def return_stats(t: float | None = None):
|
||||
mem_mon_read = shared.mem_mon.read()
|
||||
ooms = mem_mon_read.pop("oom")
|
||||
retries = mem_mon_read.pop("retries")
|
||||
vram = {k: v//1048576 for k, v in mem_mon_read.items()}
|
||||
vram = {k: v // 1048576 for k, v in mem_mon_read.items()}
|
||||
peak = max(vram['active_peak'], vram['reserved_peak'], vram['used'])
|
||||
used = round(100.0 * peak / vram['total']) if vram['total'] > 0 else 0
|
||||
if peak > 0:
|
||||
gpu += f"| GPU {peak} MB"
|
||||
gpu += f"| 🕮 GPU {peak} MB"
|
||||
gpu += f" {used}%" if used > 0 else ''
|
||||
gpu += f" | retries {retries} oom {ooms}" if retries > 0 or ooms > 0 else ''
|
||||
ram = ram_stats()
|
||||
if ram['used'] > 0:
|
||||
cpu += f"| RAM {ram['used']} GB"
|
||||
cpu += f" RAM {ram['used']} GB"
|
||||
cpu += f" {round(100.0 * ram['used'] / ram['total'])}%" if ram['total'] > 0 else ''
|
||||
return f"<div class='performance'><p>{elapsed_text} {summary} {gpu} {cpu}</p></div>"
|
||||
return f"<div class='performance hint' id='control-performance'><p>{elapsed_text} {summary} {gpu} {cpu}</p></div>"
|
||||
|
||||
|
||||
def return_controls(res, t: float | None = None):
|
||||
|
||||
Vendored
+4
-4
@@ -15515,8 +15515,7 @@ async function setHints() {
|
||||
}
|
||||
async function applyHintToElement(el2) {
|
||||
if (!localeData.data || localeData.data.length === 0) return;
|
||||
if (!el2.textContent) return;
|
||||
const isValidElement = el2.tagName === "BUTTON" || el2.tagName === "H2" || el2.tagName === "SPAN" && (el2.parentElement?.tagName === "LABEL" || el2.parentElement?.classList.contains("label-wrap") || el2.dataset.testid === "block-info");
|
||||
const isValidElement = el2.tagName === "BUTTON" || el2.tagName === "H2" || el2.classList.contains("hint") || el2.tagName === "SPAN" && (el2.parentElement?.tagName === "LABEL" || el2.parentElement?.classList.contains("label-wrap") || el2.dataset.testid === "block-info");
|
||||
if (!isValidElement) return;
|
||||
let found;
|
||||
if (el2.id) found = localeData.data.find((l) => l.id && (l.id === el2.id || el2.id.endsWith(l.id)));
|
||||
@@ -15524,7 +15523,7 @@ async function applyHintToElement(el2) {
|
||||
if (el2.dataset.original) found = localeData.data.find((l) => l.label.toLowerCase().trim() === el2.dataset.original.toLowerCase().trim());
|
||||
else found = localeData.data.find((l) => l.label.toLowerCase().trim() === el2.textContent.toLowerCase().trim());
|
||||
}
|
||||
if (found?.localized?.length > 0) {
|
||||
if (el2.textContent && el2.textContent.length > 0 && found?.localized?.length > 0) {
|
||||
if (!el2.dataset.original) el2.dataset.original = el2.textContent;
|
||||
replaceTextContent(el2, found.localized);
|
||||
}
|
||||
@@ -15543,11 +15542,12 @@ function initializeDOMObserver() {
|
||||
...Array.from(gradioApp().querySelectorAll("h1")),
|
||||
...Array.from(gradioApp().querySelectorAll("h2")),
|
||||
...Array.from(gradioApp().querySelectorAll("h3")),
|
||||
...Array.from(gradioApp().querySelectorAll(".hint")),
|
||||
...Array.from(node.querySelectorAll("label > span")),
|
||||
...Array.from(node.querySelectorAll(".label-wrap > span")),
|
||||
...Array.from(node.querySelectorAll('span[data-testid="block-info"]'))
|
||||
];
|
||||
if (node.matches && (node.matches("button") || node.matches("h1") || node.matches("h2") || node.matches("h3") || node.matches("label > span") || node.matches(".label-wrap > span") || node.matches('span[data-testid="block-info"]'))) {
|
||||
if (node.matches && (node.matches("button") || node.matches("h1") || node.matches("h2") || node.matches("h3") || node.matches("label > span") || node.matches(".hint") || node.matches(".label-wrap > span") || node.matches('span[data-testid="block-info"]'))) {
|
||||
elements.push(node);
|
||||
}
|
||||
elements.forEach((el2) => applyHintToElement(el2));
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+6
-2
@@ -260,6 +260,7 @@ function createLocaleJSON() {
|
||||
...Array.from<any>(gradioApp().querySelectorAll('h1')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('h2')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('h3')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('.hint')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('label > span')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('.label-wrap > span')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('span[data-testid="block-info"]')),
|
||||
@@ -362,11 +363,12 @@ export async function setHints() {
|
||||
// Apply hints to a single element immediately
|
||||
async function applyHintToElement(el) {
|
||||
if (!localeData.data || localeData.data.length === 0) return;
|
||||
if (!el.textContent) return;
|
||||
// if (!el.textContent) return;
|
||||
|
||||
// check if element matches our selector criteria
|
||||
const isValidElement = el.tagName === 'BUTTON'
|
||||
|| el.tagName === 'H2'
|
||||
|| el.classList.contains('hint')
|
||||
|| (el.tagName === 'SPAN' && (el.parentElement?.tagName === 'LABEL' || el.parentElement?.classList.contains('label-wrap') || el.dataset.testid === 'block-info'));
|
||||
if (!isValidElement) return;
|
||||
|
||||
@@ -377,7 +379,7 @@ async function applyHintToElement(el) {
|
||||
else found = localeData.data.find((l) => l.label.toLowerCase().trim() === el.textContent.toLowerCase().trim());
|
||||
}
|
||||
|
||||
if (found?.localized?.length > 0) { // apply localization if found
|
||||
if (el.textContent && el.textContent.length > 0 && found?.localized?.length > 0) { // apply localization if found
|
||||
if (!el.dataset.original) el.dataset.original = el.textContent;
|
||||
replaceTextContent(el, found.localized);
|
||||
}
|
||||
@@ -404,6 +406,7 @@ function initializeDOMObserver() {
|
||||
...Array.from<any>(gradioApp().querySelectorAll('h1')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('h2')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('h3')),
|
||||
...Array.from<any>(gradioApp().querySelectorAll('.hint')),
|
||||
...Array.from<any>(node.querySelectorAll('label > span')),
|
||||
...Array.from<any>(node.querySelectorAll('.label-wrap > span')),
|
||||
...Array.from<any>(node.querySelectorAll('span[data-testid="block-info"]')),
|
||||
@@ -416,6 +419,7 @@ function initializeDOMObserver() {
|
||||
|| node.matches('h2')
|
||||
|| node.matches('h3')
|
||||
|| node.matches('label > span')
|
||||
|| node.matches('.hint')
|
||||
|| node.matches('.label-wrap > span')
|
||||
|| node.matches('span[data-testid="block-info"]')
|
||||
)) {
|
||||
|
||||
Reference in New Issue
Block a user