Skip to content

Fix SyntaxError in YOLOWorldDetector.reparameterize#652

Open
amrutur wants to merge 1 commit intoAILab-CVC:masterfrom
amrutur:fix/reparameterize-syntaxerror
Open

Fix SyntaxError in YOLOWorldDetector.reparameterize#652
amrutur wants to merge 1 commit intoAILab-CVC:masterfrom
amrutur:fix/reparameterize-syntaxerror

Conversation

@amrutur
Copy link
Copy Markdown

@amrutur amrutur commented Apr 14, 2026

Summary

yolo_world/models/detectors/yolo_world.py:61 contains a literal SyntaxError:

self.text_feats, None = self.backbone.forward_text(texts)

None is a Python keyword and cannot appear on the left-hand side of an
assignment. Importing the package fails immediately with:

SyntaxError: cannot assign to None

Introduced in commit 1f12bca ("add mask"), 2025-02-27.

Fix

Both forward_text() implementations in yolo_world/models/backbones/mm_backbone.py
return a single tensor, not a tuple:

  • PseudoLanguageBackbone.forward_text at L172 returns text_embeds
  • MultiModalYOLOBackbone.forward_text at L234 returns txt_feats

The other two call sites at L163 and L168 treat the return value as a
single value. The tuple-unpack here was spurious.

Fix by dropping the unpack:

self.text_feats = self.backbone.forward_text(texts)

This is a one-line, one-file change.

Test plan

  • python -c "import yolo_world" succeeds
  • from yolo_world.models.detectors import YOLOWorldDetector succeeds
  • demo/image_demo.py completes end-to-end with V2.1 L checkpoints (verified locally against both l_stage1-7d280586.pth at 640 resolution and l_stage2-b3e3dc3f.pth at 1280 resolution, since image_demo.py calls model.reparameterize(texts) at runtime)

🤖 Generated with Claude Code

The line

    self.text_feats, None = self.backbone.forward_text(texts)

is a SyntaxError — None cannot appear on the LHS of an assignment.
It was introduced in 1f12bca ("add mask") and causes
`import yolo_world` to fail.

Both implementations of `forward_text()` in mm_backbone.py return a
single tensor (not a tuple), and the other two call sites
(lines 163, 168) treat the return value as a single value.

Fix by dropping the unpack entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant