Fix two transformers-v5 AttributeErrors in Florence-2 remote code

#122

transformers v5 changed two things this repo's remote code still assumes the old behavior for (see MIGRATION_GUIDE_V5.md):

  1. forced_bos_token_id is no longer auto-set as a config instance attribute ('Modeling > Generate'). Florence2LanguageConfig read self.forced_bos_token_id assuming the old behavior.
  2. additional_special_tokens was renamed to extra_special_tokens. Florence2Processor.__init__ read the old attribute name, raising AttributeError.

Both fixes are minimal and backward compatible with transformers v4. Related: kijai/ComfyUI-Florence2#187, #199, Comfy-Org/ComfyUI#12277, Lightricks/ComfyUI-LTXVideo#394 all hit the symptom of bug 1. #119 also contains fixes for both but bundles them with a full-repo rewrite that corrupts config.json (swaps in Florence-2-base's architecture dimensions), so it's not safe to merge as-is -- this PR is scoped to just these two AttributeErrors. Supersedes #121, which fixed bug 1 alone and later had bug 2 added as a second commit; this PR bundles both from the start instead.

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment