diff --git a/.eslintrc.json b/.eslintrc.json
index 4f0cb228a..4e5d16a65 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -86,7 +86,10 @@
// logMonitor.js
"jobStatusEl": "readonly",
// loader.js
- "removeSplash": "readonly"
+ "removeSplash": "readonly",
+ // nvml.js
+ "initNVML": "readonly",
+ "disableNVML": "readonly"
},
"ignorePatterns": [
"node_modules",
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1d9950d7..84c5eb825 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -140,6 +140,7 @@ or even free speedups and quality improvements (regardless of which workflows yo
- **CUDA**:
- default updated to `torch` *2.1.0* with cuda *12.1*
- testing moved to `torch` *2.2.0-dev/cu122*
+ - check out *generate context menu -> show nvml*
- **Intel Arc/IPEX**:
- tons of optimizations, built-in binary wheels for Windows
i have to say, intel arc/ipex is getting to be quite a player, especially with openvino
diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js
index 5aaeba3cd..fab220da4 100644
--- a/javascript/contextMenus.js
+++ b/javascript/contextMenus.js
@@ -9,13 +9,8 @@ const contextMenuInit = () => {
const posy = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
const oldMenu = gradioApp().querySelector('#context-menu');
if (oldMenu) oldMenu.remove();
- const tabButton = uiCurrentTab;
- const baseStyle = window.getComputedStyle(tabButton);
const contextMenu = document.createElement('nav');
contextMenu.id = 'context-menu';
- contextMenu.style.background = baseStyle.background;
- contextMenu.style.color = baseStyle.color;
- contextMenu.style.fontFamily = baseStyle.fontFamily;
contextMenu.style.top = `${posy}px`;
contextMenu.style.left = `${posx}px`;
const contextMenuList = document.createElement('ul');
@@ -90,41 +85,27 @@ const appendContextMenuOption = initResponse[0];
const removeContextMenuOption = initResponse[1];
const addContextMenuEventListener = initResponse[2];
-(function () { // eslint-disable-line
+function initContextMenu() {
// Start example Context Menu Items
const generateOnRepeat = (genbuttonid, interruptbuttonid) => {
const genbutton = gradioApp().querySelector(genbuttonid);
const busy = document.getElementById('progressbar')?.style.display === 'block';
if (!busy) genbutton.click();
clearInterval(window.generateOnRepeatInterval);
- window.generateOnRepeatInterval = setInterval(
- () => {
- const pbBusy = document.getElementById('progressbar')?.style.display === 'block';
- if (!pbBusy) genbutton.click();
- },
- 500,
- );
+ window.generateOnRepeatInterval = setInterval(() => {
+ const pbBusy = document.getElementById('progressbar')?.style.display === 'block';
+ if (!pbBusy) genbutton.click();
+ }, 500);
};
+ const cancelGenerateForever = () => clearInterval(window.generateOnRepeatInterval);
appendContextMenuOption('#txt2img_generate', 'Generate forever', () => generateOnRepeat('#txt2img_generate', '#txt2img_interrupt'));
appendContextMenuOption('#img2img_generate', 'Generate forever', () => generateOnRepeat('#img2img_generate', '#img2img_interrupt'));
- const cancelGenerateForever = () => clearInterval(window.generateOnRepeatInterval);
-
- appendContextMenuOption('#txt2img_interrupt', 'Cancel generate forever', cancelGenerateForever);
appendContextMenuOption('#txt2img_generate', 'Cancel generate forever', cancelGenerateForever);
- appendContextMenuOption('#img2img_interrupt', 'Cancel generate forever', cancelGenerateForever);
appendContextMenuOption('#img2img_generate', 'Cancel generate forever', cancelGenerateForever);
- appendContextMenuOption(
- '#roll',
- 'Roll three',
- () => {
- const rollbutton = getUICurrentTabContent().querySelector('#roll');
- setTimeout(() => { rollbutton.click(); }, 100);
- setTimeout(() => { rollbutton.click(); }, 200);
- setTimeout(() => { rollbutton.click(); }, 300);
- },
- );
-}());
-// End example Context Menu Items
+ appendContextMenuOption('#txt2img_generate', 'Show NVML overlay', initNVML);
+ appendContextMenuOption('#txt2img_generate', 'Hide NVML overlay', disableNVML);
+}
+onUiLoaded(initContextMenu);
onAfterUiUpdate(() => addContextMenuEventListener());
diff --git a/javascript/nvml.js b/javascript/nvml.js
index 6f4dd2d56..63a5b5371 100644
--- a/javascript/nvml.js
+++ b/javascript/nvml.js
@@ -46,20 +46,26 @@ async function updateNVML() {
}
async function initNVML() {
- nvmlEl = document.createElement('div');
- nvmlEl.className = 'nvml';
- nvmlEl.id = 'nvml';
- nvmlTable = document.createElement('table');
- nvmlTable.className = 'nvml-table';
- nvmlTable.id = 'nvml-table';
- nvmlTable.innerHTML = `
-
-