fix: core-pipeline crash fixes + effective-python audit (9 commits)#17
Open
forkni wants to merge 9 commits into
Open
fix: core-pipeline crash fixes + effective-python audit (9 commits)#17forkni wants to merge 9 commits into
forkni wants to merge 9 commits into
Conversation
When use_cuda_ipc_output=True and output_type='pt', postprocess_image()
exports the frame and returns None. The old code fed that None to
self.safety_checker, which called torchvision T.Resize(None) and raised:
TypeError: Unexpected type <class 'NoneType'>
This crashed the streaming loop every frame, silently, because the except
block logged and retried.
Root cause: the CUDA-IPC fast-path lives at the TOP of postprocess_image
(lines 928-948) and returns None before any output-type branch runs. The
post-hoc safety check then did denormalized = image (the None) for pt path.
Two bugs fixed:
1. The crash: None passed to NSFWDetectorEngine.image_transforms (torchvision)
2. The silent bypass: even without the crash, the NSFW substitution was dead
code on the IPC path -- the frame was already exported before the check ran.
Fix: extract _apply_safety_checker() to operate on the raw diffusion-range
[-1, 1] pipeline tensor BEFORE postprocess_image. Both txt2img and img2img
now call it first; the substituted (-1.0 = black) or previous clean tensor
flows into postprocess_image and out through every output path including IPC.
Fallback tensor: torch.full_like(t, -1.0) maps to 0.0 after
_denormalize_on_gpu -> true black on all paths (pt, np, pil, CUDA-IPC).
Previous-frame fallback caches via _prev_clean_tensor (diffusion range).
nsfw_fallback_img / set_nsfw_fallback_img remain defined but are no longer
read by the inference path (dead code, removal deferred to avoid churn).
Regression test: tests/unit/test_safety_checker.py -- 8 CPU-only pytest
cases covering: no-None contract, blank/previous fallback, clean passthrough,
disabled bypass, first-frame-flagged edge case, cache behaviour.
Related gap (not fixed here): _process_skip_diffusion has a TODO for the
safety checker call and still bypasses the check entirely.
…et_characteristics
… on empty seed_list
…oss all build/load paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Branch
forkni/core-pipeline-audit-crash-fixes->feat/cuda-ipc-output