fix(cosmos2_5_predict): guard text safety check with isinstance like the video path#13867
Open
Anai-Guo wants to merge 1 commit into
Open
fix(cosmos2_5_predict): guard text safety check with isinstance like the video path#13867Anai-Guo wants to merge 1 commit into
Anai-Guo wants to merge 1 commit into
Conversation
…video path The video safety branch guards with isinstance(self.safety_checker, CosmosSafetyChecker), but the text safety branch only checks 'is not None'. When safety_checker is a non-None object that is not a CosmosSafetyChecker, the text path raises AttributeError on check_text_safety. Align the two guards so the text path degrades gracefully like the video path.
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.
What does this PR do?
Fixes #13864.
In
Cosmos2_5_PredictBasePipeline.__call__, the text safety check and the video safety check guardself.safety_checkerinconsistently:if isinstance(self.safety_checker, CosmosSafetyChecker):if self.safety_checker is not None:When
safety_checkeris a non-Noneobject that is not aCosmosSafetyChecker(e.g. a user passes the wrong object viasafety_checker=), the text path callsself.safety_checker.check_text_safety(...)and raises:while the video path silently skips. This PR aligns the text guard with the existing
isinstanceguard used by the video path, so both branches degrade gracefully on an unexpectedsafety_checkertype.Noneis still rejected earlier in__call__with the explicit licenseValueError, so this does not weaken the default safety behavior.Before submitting
isinstance(self.safety_checker, CosmosSafetyChecker)guard already used for the video safety check in the same method.🤖 Generated with Claude Code