AutoTokenizer tries to load the model config to detect tokenizer type,
which fails because transformers 5.x CONFIG_MAPPING doesn't know
florence2_language. Use BartTokenizerFast directly with tokenizer.json
fallback for models that use different tokenizer formats.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When AutoTokenizer fails (e.g. Florence-2-Flux-Large), fall back to
loading tokenizer.json directly via the tokenizers library and wrap
it with PreTrainedTokenizerFast, extracting special tokens from
tokenizer_config.json manually.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Some Florence2 variants (e.g. Florence-2-Flux-Large) have added_tokens
in a format that fast tokenizers in transformers 5.x cannot parse.
Fall back to slow tokenizer on TypeError.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Some Florence2 variants (e.g. Florence-2-Flux-Large) use a RoBERTa
tokenizer. AutoTokenizer auto-detects the correct tokenizer class.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In transformers 5.x, passing do_resize=None to CLIPImageProcessor
disables resizing instead of using the configured default. Filter out
None values so the processor uses its init settings (768x768 resize).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The florence2_models directory needs an __init__.py to be a proper
Python package, and imports from py/florence2_ultra.py need to use
relative imports (..florence2_models) since it's a sibling subpackage.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Uses local Florence2 modules with accelerate-based weight loading and
a custom Florence2Processor for transformers >= 5.0.0, while keeping
the existing loading path for older versions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In transformers 5.x, forced_bos_token_id was moved from PretrainedConfig
to GenerationConfig. Florence2's custom config accesses this attribute
during init, causing an AttributeError that prevents model loading and
leads to a NoneType crash when the processor is later called.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>