Skip to content

fix(cosmos2_5_predict): guard text safety check with isinstance like the video path#13867

Open
Anai-Guo wants to merge 1 commit into
huggingface:mainfrom
Anai-Guo:fix-cosmos25-text-safety-guard
Open

fix(cosmos2_5_predict): guard text safety check with isinstance like the video path#13867
Anai-Guo wants to merge 1 commit into
huggingface:mainfrom
Anai-Guo:fix-cosmos25-text-safety-guard

Conversation

@Anai-Guo
Copy link
Copy Markdown

@Anai-Guo Anai-Guo commented Jun 4, 2026

What does this PR do?

Fixes #13864.

In Cosmos2_5_PredictBasePipeline.__call__, the text safety check and the video safety check guard self.safety_checker inconsistently:

  • Video path: if isinstance(self.safety_checker, CosmosSafetyChecker):
  • Text path: if self.safety_checker is not None:

When safety_checker is a non-None object that is not a CosmosSafetyChecker (e.g. a user passes the wrong object via safety_checker=), the text path calls self.safety_checker.check_text_safety(...) and raises:

AttributeError: 'Cosmos2_5_PredictBasePipeline' object has no attribute 'check_text_safety'

while the video path silently skips. This PR aligns the text guard with the existing isinstance guard used by the video path, so both branches degrade gracefully on an unexpected safety_checker type. None is still rejected earlier in __call__ with the explicit license ValueError, so this does not weaken the default safety behavior.

Before submitting

  • This change is consistent with the existing isinstance(self.safety_checker, CosmosSafetyChecker) guard already used for the video safety check in the same method.

🤖 Generated with Claude Code

…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.
@github-actions github-actions Bot added fixes-issue size/S PR with diff < 50 LOC pipelines labels Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'Cosmos2_5_PredictBasePipeline' object has no attribute 'check_text_safety'

1 participant