Skip to content

Commit 17c8fe9

Browse files
committed
cleanup performance tags
Signed-off-by: Vladimir Mandic <mandic00@live.com>
1 parent 51a0eaa commit 17c8fe9

7 files changed

Lines changed: 21 additions & 15 deletions

File tree

modules/timer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def summary(self, min_time=default_min_time, max_time=-1, total=True):
4949
additions = [x for x in self.records.items() if x[1] >= min_time]
5050
if max_time > 0:
5151
additions = [x for x in additions if x[1] <= max_time]
52+
if not total:
53+
additions = [x for x in additions if x[0] != 'total']
5254
additions = sorted(additions, key=lambda x: x[1], reverse=True)
5355
if not additions:
5456
return res

modules/ui_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def create_output_panel(tabname, preview=True, prompt=None, height=None, transfe
342342
html_info = gr.HTML(elem_id=f'html_info_{tabname}', elem_classes="infotext", visible=False) # contains raw infotext as returned by wrapped call
343343
html_info_formatted = gr.HTML(elem_id=f'html_info_formatted_{tabname}', elem_classes="infotext", visible=True) # contains html formatted infotext
344344
html_info.change(fn=infotext_to_html, inputs=[html_info], outputs=[html_info_formatted], show_progress='hidden')
345-
html_log = gr.HTML(elem_id=f'html_log_{tabname}')
345+
html_log = gr.HTML(elem_id=f'html_log_{tabname}', elem_classes=["hint"])
346346
generation_info = gr.Textbox(visible=False, elem_id=f'generation_info_{tabname}')
347347
generation_info_button = gr.Button(visible=False, elem_id=f"{tabname}_generation_info_button")
348348

modules/ui_control.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,26 @@ def return_stats(t: float | None = None):
2626
elapsed = time.perf_counter() - t
2727
elapsed_m = int(elapsed // 60)
2828
elapsed_s = elapsed % 60
29-
elapsed_text = f"Time: {elapsed_m}m {elapsed_s:.2f}s |" if elapsed_m > 0 else f"Time: {elapsed_s:.2f}s |"
29+
elapsed_text = f" {elapsed_m}m {elapsed_s:.2f}s |" if elapsed_m > 0 else f" {elapsed_s:.2f}s |"
3030
summary = timer.process.summary(total=False).replace('=', ' ')
3131
gpu = ''
3232
cpu = ''
3333
if not shared.mem_mon.disabled:
3434
mem_mon_read = shared.mem_mon.read()
3535
ooms = mem_mon_read.pop("oom")
3636
retries = mem_mon_read.pop("retries")
37-
vram = {k: v//1048576 for k, v in mem_mon_read.items()}
37+
vram = {k: v // 1048576 for k, v in mem_mon_read.items()}
3838
peak = max(vram['active_peak'], vram['reserved_peak'], vram['used'])
3939
used = round(100.0 * peak / vram['total']) if vram['total'] > 0 else 0
4040
if peak > 0:
41-
gpu += f"| GPU {peak} MB"
41+
gpu += f"| 🕮 GPU {peak} MB"
4242
gpu += f" {used}%" if used > 0 else ''
4343
gpu += f" | retries {retries} oom {ooms}" if retries > 0 or ooms > 0 else ''
4444
ram = ram_stats()
4545
if ram['used'] > 0:
46-
cpu += f"| RAM {ram['used']} GB"
46+
cpu += f" RAM {ram['used']} GB"
4747
cpu += f" {round(100.0 * ram['used'] / ram['total'])}%" if ram['total'] > 0 else ''
48-
return f"<div class='performance'><p>{elapsed_text} {summary} {gpu} {cpu}</p></div>"
48+
return f"<div class='performance hint' id='control-performance'><p>{elapsed_text} {summary} {gpu} {cpu}</p></div>"
4949

5050

5151
def return_controls(res, t: float | None = None):

ui/dist/sdnext.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15515,16 +15515,15 @@ async function setHints() {
1551515515
}
1551615516
async function applyHintToElement(el2) {
1551715517
if (!localeData.data || localeData.data.length === 0) return;
15518-
if (!el2.textContent) return;
15519-
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");
15518+
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");
1552015519
if (!isValidElement) return;
1552115520
let found;
1552215521
if (el2.id) found = localeData.data.find((l) => l.id && (l.id === el2.id || el2.id.endsWith(l.id)));
1552315522
if (!found) {
1552415523
if (el2.dataset.original) found = localeData.data.find((l) => l.label.toLowerCase().trim() === el2.dataset.original.toLowerCase().trim());
1552515524
else found = localeData.data.find((l) => l.label.toLowerCase().trim() === el2.textContent.toLowerCase().trim());
1552615525
}
15527-
if (found?.localized?.length > 0) {
15526+
if (el2.textContent && el2.textContent.length > 0 && found?.localized?.length > 0) {
1552815527
if (!el2.dataset.original) el2.dataset.original = el2.textContent;
1552915528
replaceTextContent(el2, found.localized);
1553015529
}
@@ -15543,11 +15542,12 @@ function initializeDOMObserver() {
1554315542
...Array.from(gradioApp().querySelectorAll("h1")),
1554415543
...Array.from(gradioApp().querySelectorAll("h2")),
1554515544
...Array.from(gradioApp().querySelectorAll("h3")),
15545+
...Array.from(gradioApp().querySelectorAll(".hint")),
1554615546
...Array.from(node.querySelectorAll("label > span")),
1554715547
...Array.from(node.querySelectorAll(".label-wrap > span")),
1554815548
...Array.from(node.querySelectorAll('span[data-testid="block-info"]'))
1554915549
];
15550-
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"]'))) {
15550+
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"]'))) {
1555115551
elements.push(node);
1555215552
}
1555315553
elements.forEach((el2) => applyHintToElement(el2));

ui/dist/sdnext.mjs.map

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

ui/setHints.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ function createLocaleJSON() {
260260
...Array.from<any>(gradioApp().querySelectorAll('h1')),
261261
...Array.from<any>(gradioApp().querySelectorAll('h2')),
262262
...Array.from<any>(gradioApp().querySelectorAll('h3')),
263+
...Array.from<any>(gradioApp().querySelectorAll('.hint')),
263264
...Array.from<any>(gradioApp().querySelectorAll('label > span')),
264265
...Array.from<any>(gradioApp().querySelectorAll('.label-wrap > span')),
265266
...Array.from<any>(gradioApp().querySelectorAll('span[data-testid="block-info"]')),
@@ -362,11 +363,12 @@ export async function setHints() {
362363
// Apply hints to a single element immediately
363364
async function applyHintToElement(el) {
364365
if (!localeData.data || localeData.data.length === 0) return;
365-
if (!el.textContent) return;
366+
// if (!el.textContent) return;
366367

367368
// check if element matches our selector criteria
368369
const isValidElement = el.tagName === 'BUTTON'
369370
|| el.tagName === 'H2'
371+
|| el.classList.contains('hint')
370372
|| (el.tagName === 'SPAN' && (el.parentElement?.tagName === 'LABEL' || el.parentElement?.classList.contains('label-wrap') || el.dataset.testid === 'block-info'));
371373
if (!isValidElement) return;
372374

@@ -377,7 +379,7 @@ async function applyHintToElement(el) {
377379
else found = localeData.data.find((l) => l.label.toLowerCase().trim() === el.textContent.toLowerCase().trim());
378380
}
379381

380-
if (found?.localized?.length > 0) { // apply localization if found
382+
if (el.textContent && el.textContent.length > 0 && found?.localized?.length > 0) { // apply localization if found
381383
if (!el.dataset.original) el.dataset.original = el.textContent;
382384
replaceTextContent(el, found.localized);
383385
}
@@ -404,6 +406,7 @@ function initializeDOMObserver() {
404406
...Array.from<any>(gradioApp().querySelectorAll('h1')),
405407
...Array.from<any>(gradioApp().querySelectorAll('h2')),
406408
...Array.from<any>(gradioApp().querySelectorAll('h3')),
409+
...Array.from<any>(gradioApp().querySelectorAll('.hint')),
407410
...Array.from<any>(node.querySelectorAll('label > span')),
408411
...Array.from<any>(node.querySelectorAll('.label-wrap > span')),
409412
...Array.from<any>(node.querySelectorAll('span[data-testid="block-info"]')),
@@ -416,6 +419,7 @@ function initializeDOMObserver() {
416419
|| node.matches('h2')
417420
|| node.matches('h3')
418421
|| node.matches('label > span')
422+
|| node.matches('.hint')
419423
|| node.matches('.label-wrap > span')
420424
|| node.matches('span[data-testid="block-info"]')
421425
)) {

0 commit comments

Comments
 (0)