diff --git a/CHANGELOG.md b/CHANGELOG.md index a7faffa90..61d0d6489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,7 @@ Less than 2 weeks since last release, here's a service-pack style update with a - catch `xet` warnings - avoid unnecessary pipe variant switching - validate pipelines on import + - fix `nudenet` process tab operations ## Update for 2025-10-18 diff --git a/modules/scripts_postprocessing.py b/modules/scripts_postprocessing.py index 95a370522..01c034e0c 100644 --- a/modules/scripts_postprocessing.py +++ b/modules/scripts_postprocessing.py @@ -101,7 +101,7 @@ class ScriptPostprocessingRunner: process_args = {} for (name, _component), value in zip(script.controls.items(), script_args): process_args[name] = value - shared.log.debug(f'Process: script={script.name} args={process_args}') + shared.log.debug(f'Process: script="{script.name}" args={process_args}') script.process(pp, **process_args) shared.state.end(jobid) diff --git a/scripts/nudenet_ext.py b/scripts/nudenet_ext.py index 021a39625..be24ea1ed 100644 --- a/scripts/nudenet_ext.py +++ b/scripts/nudenet_ext.py @@ -1,3 +1,4 @@ +import time import gradio as gr from modules import scripts, scripts_postprocessing, processing, images from scripts.nudenet import nudenet # pylint: disable=no-name-in-module @@ -66,17 +67,20 @@ def process( words='', ): from modules.shared import state, log - if enabled and p is not None and pp is not None and pp.image is not None: + if enabled and pp is not None and pp.image is not None: if nudenet.detector is None: nudenet.detector = nudenet.NudeDetector(providers=['CUDAExecutionProvider', 'CPUExecutionProvider']) # loads and initializes model once + t0 = time.time() nudes = nudenet.detector.censor(image=pp.image, method=method, min_score=score, censor=censor, blocks=blocks, overlay=overlay) + t1 = time.time() if len(nudes.censored) > 0: # Check if there are any censored areas if not copy: pp.image = nudes.output else: info = processing.create_infotext(p) images.save_image(nudes.output, path=p.outpath_samples, seed=p.seed, prompt=p.prompt, info=info, p=p, suffix="-censored") - meta = '; '.join([f'{d["label"]}:{d["score"]}' for d in nudes.detections]) # add all metadata + dct = {d["label"]: d["score"] for d in nudes.detections} + meta = '; '.join([f'{k}:{v}' for k, v in dct.items()]) # add all metadata nsfw = any([d["label"] in nudenet.nsfw for d in nudes.detections]) # noqa:C419 # pylint: disable=use-a-generator if metadata and p is not None: p.extra_generation_params["NudeNet"] = meta @@ -84,7 +88,7 @@ def process( if metadata and hasattr(pp, 'info'): pp.info['NudeNet'] = meta pp.info['NSFW'] = nsfw - log.debug(f'NudeNet detect: {meta} nsfw={nsfw}') + log.debug(f'NudeNet detect: {dct} nsfw={nsfw} time={(t1 - t0):.2f}') if lang and p is not None: prompts = '.\n'.join(p.all_prompts) if p.all_prompts else p.prompt allowed = [a.strip() for a in allowed.split(',')] if allowed else []