mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
preview check for output panel visibility
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
+4
-1
@@ -10,12 +10,15 @@
|
||||
- **SDNQ-Attention**
|
||||
modelled after *sage-attention*, but modified to support AMD and Intel GPUs in addition to nVidia
|
||||
- **SDNQ** support for NPU during quantization and inference
|
||||
- add option: force dtype on load
|
||||
- add option: *compute settings -> force dtype on load*
|
||||
use to force model components to override loading with desired dtype regardless of component config
|
||||
- add option: *backend settings -> force sychronize*
|
||||
enabled by default, disable to speed up processing but may cause image corruptions, especially during preview
|
||||
- **UI**
|
||||
- dynamic visibility of image controls
|
||||
- improve main panel positioning: *portrait/landscape*
|
||||
- improved gallery performance
|
||||
- preview now only runs if output panel is visible
|
||||
- ModernUI: old *txt2img* and *img2img* tabs are marked as legacy and hidden by default
|
||||
- StandardUI: marked as legacy
|
||||
- **Internal**
|
||||
|
||||
@@ -55,10 +55,14 @@ def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict | No
|
||||
if kwargs is None:
|
||||
kwargs = {}
|
||||
t0 = time.time()
|
||||
if devices.backend == "ipex":
|
||||
torch.xpu.synchronize(devices.device)
|
||||
elif devices.backend in {"cuda", "zluda", "rocm"}:
|
||||
torch.cuda.synchronize(devices.device)
|
||||
|
||||
if shared.opts.torch_sync:
|
||||
if devices.backend == "ipex":
|
||||
torch.xpu.synchronize(devices.device)
|
||||
elif devices.backend in {"cuda", "zluda", "rocm"}:
|
||||
torch.cuda.synchronize(devices.device)
|
||||
|
||||
t1 = time.time()
|
||||
|
||||
if shared.state.paused:
|
||||
log.debug('Sampling paused')
|
||||
@@ -84,12 +88,9 @@ def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict | No
|
||||
shared.state.step()
|
||||
if shared.state.interrupted or shared.state.skipped:
|
||||
raise AssertionError('Interrupted...')
|
||||
if latents is None:
|
||||
return kwargs
|
||||
elif shared.opts.nan_skip:
|
||||
assert not torch.isnan(latents[..., 0, 0]).all(), f'NaN detected at step {step}: Skipping...'
|
||||
if p is None:
|
||||
if latents is None or p is None:
|
||||
return kwargs
|
||||
|
||||
if len(getattr(p, 'ip_adapter_names', [])) > 0 and p.ip_adapter_names[0] != 'None':
|
||||
ip_adapter_scales = list(p.ip_adapter_scales)
|
||||
ip_adapter_starts = list(p.ip_adapter_starts)
|
||||
@@ -220,6 +221,7 @@ def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict | No
|
||||
p.extra_generation_params["Sigma adjust"] = _sigma_adjust
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
except Exception as e:
|
||||
global warned # pylint: disable=global-statement
|
||||
if not warned:
|
||||
@@ -229,6 +231,8 @@ def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict | No
|
||||
# errors.display(e, 'Callback')
|
||||
if shared.cmd_opts.profile and shared.profiler is not None:
|
||||
shared.profiler.step()
|
||||
t1 = time.time()
|
||||
timer.process.add('callback', t1 - t0)
|
||||
|
||||
t2 = time.time()
|
||||
timer.process.add('sync', t1 - t0)
|
||||
timer.process.add('callback', t2 - t1)
|
||||
return kwargs
|
||||
|
||||
@@ -282,6 +282,7 @@ def create_settings(cmd_opts):
|
||||
"cudnn_deterministic": OptionInfo(False, "Deterministic mode"),
|
||||
"diffusers_fuse_projections": OptionInfo(False, "Fused projections"),
|
||||
"torch_expandable_segments": OptionInfo(False, "Expandable segments"),
|
||||
"torch_sync": OptionInfo(True, "Force synchronize"),
|
||||
"cudnn_enabled": OptionInfo("default", "cuDNN enabled", gr.Radio, {"choices": ["default", "true", "false"]}),
|
||||
"cudnn_benchmark": OptionInfo(devices.backend != "rocm", "cuDNN full-depth benchmark"),
|
||||
"cudnn_benchmark_limit": OptionInfo(10, "cuDNN benchmark limit", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1}),
|
||||
|
||||
Vendored
+43
-24
@@ -10311,7 +10311,6 @@ var activePromptTextarea = {};
|
||||
var sortVal = -1;
|
||||
var totalCards = -1;
|
||||
var lastTab = "control";
|
||||
var referenceSearch;
|
||||
var getENActiveTab = () => {
|
||||
let tabName = "";
|
||||
if (gradioApp().getElementById("txt2img_prompt")?.checkVisibility() || gradioApp().getElementById("txt2img_generate")?.checkVisibility()) tabName = "txt2img";
|
||||
@@ -10424,20 +10423,37 @@ async function filterExtraNetworksForTab(searchTerm) {
|
||||
const allPages = Array.from(gradioApp().querySelectorAll(".extra-network-cards"));
|
||||
const pages = allPages.filter((el2) => el2.id.toLowerCase().includes(pagename.toLowerCase()));
|
||||
for (const pg of pages) {
|
||||
found = 0;
|
||||
items = 0;
|
||||
const cards = Array.from(pg.querySelectorAll(".card") || []);
|
||||
items += cards.length;
|
||||
if (referenceSearch) {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = elem.dataset.tags.toLowerCase().includes(referenceSearch.toLowerCase()) ? "" : "none";
|
||||
});
|
||||
} else if (searchTerm === "" || searchTerm === "all/") {
|
||||
if (searchTerm === "" || searchTerm === "all/") {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = "";
|
||||
});
|
||||
}
|
||||
if (searchTerm === "local/") {
|
||||
} else if (searchTerm === "reference/") {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = elem.dataset.name.toLowerCase().includes("reference/") && elem.dataset.tags === "" ? "" : "none";
|
||||
});
|
||||
} else if (searchTerm === "distilled/") {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = elem.dataset.tags.toLowerCase().includes("distilled") ? "" : "none";
|
||||
});
|
||||
} else if (searchTerm === "community/") {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = elem.dataset.tags.toLowerCase().includes("community") ? "" : "none";
|
||||
});
|
||||
} else if (searchTerm === "cloud/") {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = elem.dataset.tags.toLowerCase().includes("cloud") ? "" : "none";
|
||||
});
|
||||
} else if (searchTerm === "quantized/") {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = elem.dataset.tags.toLowerCase().includes("quantized") ? "" : "none";
|
||||
});
|
||||
} else if (searchTerm === "nunchaku/") {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = elem.dataset.tags.toLowerCase().includes("nunchaku") ? "" : "none";
|
||||
});
|
||||
} else if (searchTerm === "local/") {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = elem.dataset.name.toLowerCase().includes("reference/") ? "none" : "";
|
||||
});
|
||||
@@ -10451,7 +10467,7 @@ async function filterExtraNetworksForTab(searchTerm) {
|
||||
cards.forEach((elem) => {
|
||||
elem.style.display = re.test(`filename: ${elem.dataset.filename}|name: ${elem.dataset.name}|tags: ${elem.dataset.tags}`) ? "" : "none";
|
||||
});
|
||||
} else if (searchTerm.trim().length > 0) {
|
||||
} else {
|
||||
const searchList = searchTerm.split("|").filter((s) => s !== "" && !s.startsWith("-")).map((s) => s.trim());
|
||||
const excludeList = searchTerm.split("|").filter((s) => s !== "" && s.trim().startsWith("-")).map((s) => s.trim().substring(1).trim());
|
||||
const searchListAll = searchList.map((s) => s.split("&").map((t) => t.trim()));
|
||||
@@ -10472,7 +10488,7 @@ async function filterExtraNetworksForTab(searchTerm) {
|
||||
found += cards.filter((elem) => elem.style.display === "").length;
|
||||
}
|
||||
const t1 = performance.now();
|
||||
log(`filterExtraNetworks: text="${searchTerm}" reference="${referenceSearch}" items=${items} match=${found} time=${Math.round(t1 - t0)}`);
|
||||
log(`filterExtraNetworks: text="${searchTerm}" items=${items} match=${found} time=${Math.round(t1 - t0)}`);
|
||||
timer(`filterExtraNetworks:${searchTerm}`, t1 - t0);
|
||||
}
|
||||
function sortExtraNetworks(fixed = "no") {
|
||||
@@ -10549,20 +10565,11 @@ function extraNetworksSearchButton(event2) {
|
||||
const tabName = getENActiveTab();
|
||||
const searchTextarea = gradioApp().querySelector(`#${tabName}_extra_search textarea`);
|
||||
const button = event2.target;
|
||||
let str = `${button.textContent.trim()}/`;
|
||||
if (str === "All/") str = "";
|
||||
if (searchTextarea) {
|
||||
const isReference = button.classList.contains("network-reference");
|
||||
if (isReference) {
|
||||
referenceSearch = str.replace("/", "");
|
||||
searchTextarea.value = "";
|
||||
} else {
|
||||
referenceSearch = void 0;
|
||||
searchTextarea.value = str;
|
||||
}
|
||||
searchTextarea.value = `${button.textContent.trim()}/`;
|
||||
updateInput(searchTextarea);
|
||||
} else {
|
||||
error(`Could not find the search textarea for the tab: ${tabName}`);
|
||||
console.error(`Could not find the search textarea for the tab: ${tabName}`);
|
||||
}
|
||||
}
|
||||
function extraNetworksFilterVersion(event2) {
|
||||
@@ -11069,9 +11076,21 @@ function requestProgress(id_task = "undefined", progressEl = null, galleryEl = n
|
||||
sendNotification();
|
||||
if (atEnd) atEnd();
|
||||
};
|
||||
const previewVisible = () => {
|
||||
try {
|
||||
return !galleryEl?.closest(".section")?.classList.contains("minimize");
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
const startLivePreview = (taskId, id_live_preview) => {
|
||||
if (window.opts.live_preview_refresh_period === 0) return;
|
||||
const request_id = window.opts.live_preview_require_focus !== false && document.hidden ? -1 : id_live_preview;
|
||||
let request_id = -1;
|
||||
if (document.hidden || !previewVisible()) {
|
||||
if (!window.opts.live_preview_require_focus) request_id = id_live_preview;
|
||||
} else {
|
||||
request_id = id_live_preview;
|
||||
}
|
||||
const onProgressHandler = (res) => {
|
||||
if (res?.debug) debug("progress:", { start: dateStart, id: request_id, res });
|
||||
lastState = res;
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+15
-1
@@ -146,9 +146,23 @@ export function requestProgress(id_task = 'undefined', progressEl = null, galler
|
||||
if (atEnd) atEnd();
|
||||
};
|
||||
|
||||
const previewVisible = () => {
|
||||
try {
|
||||
return !galleryEl?.closest('.section')?.classList.contains('minimize');
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
const startLivePreview = (taskId: string, id_live_preview: number) => {
|
||||
if (window.opts.live_preview_refresh_period === 0) return;
|
||||
const request_id = (window.opts.live_preview_require_focus !== false && document.hidden) ? -1 : id_live_preview;
|
||||
|
||||
let request_id = -1;
|
||||
if (document.hidden || !previewVisible()) {
|
||||
if (!window.opts.live_preview_require_focus) request_id = id_live_preview;
|
||||
} else {
|
||||
request_id = id_live_preview;
|
||||
}
|
||||
|
||||
const onProgressHandler = (res) => {
|
||||
if (res?.debug) debug('progress:', { start: dateStart, id: request_id, res });
|
||||
|
||||
Reference in New Issue
Block a user