Skip to content

Fix SAM2 server error - #9588

Open
shanedk wants to merge 3 commits into
invoke-ai:mainfrom
shanedk:fix_sam2
Open

shanedk wants to merge 3 commits into
invoke-ai:mainfrom
shanedk:fix_sam2

Conversation

@shanedk

@shanedk shanedk commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix for SAM2 (Segment Anything 2) crashing with KeyError: 'reshaped_input_sizes' / AttributeError

Versions: InvokeAI 6.13.7 and 6.14.1, with transformers 5.5.4.

Cause: Invoke's SAM2 wrapper still passes reshaped_input_sizes to the SAM2 processor. Transformers 5.x removed that field from both the processor output and post_process_masks(), so SAM2 crashes as soon as it tries to read it. SAM1 isn't affected.

Note: The patch only passes the field if it's actually there, so it's safe on older transformers too.

Related Issues / Discussions

Closes #9555

See Discord discussion: https://discord.com/channels/1020123559063990373/1542112507978846208

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@github-actions github-actions Bot added python PRs that change python files backend PRs that change backend files labels Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files python PRs that change python files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant