Commit Graph
13 Commits
Author SHA1 Message Date
Gang WenandClaude Opus 4.6 acbe51c5a2 Use BartTokenizerFast instead of AutoTokenizer to avoid config loading
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>
2026-04-07 20:03:24 +02:00
Gang WenandClaude Opus 4.6 1130a5f117 Fix tokenizer loading for models with incompatible added_tokens format
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>
2026-04-07 20:01:28 +02:00
Gang WenandClaude Opus 4.6 aa016d91de Add slow tokenizer fallback for models with incompatible added_tokens
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>
2026-04-07 19:59:26 +02:00
Gang WenandClaude Opus 4.6 8d1bfd3874 Use AutoTokenizer instead of BartTokenizerFast for broader model support
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>
2026-04-07 19:57:01 +02:00
Gang WenandClaude Opus 4.6 caafe797f7 Fix image processor not resizing: filter None kwargs in Florence2Processor
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>
2026-04-07 19:33:50 +02:00
Gang WenandClaude Opus 4.6 6b60e25cdc Add debug logging for pixel_values shape in run_example
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 19:31:12 +02:00
Gang WenandClaude Opus 4.6 21549b7bfe Fix florence2_models imports: add __init__.py and use relative imports
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>
2026-04-07 19:27:39 +02:00
Gang WenandClaude Opus 4.6 fd34c3d5d8 Add debug logging to Florence2 model loading path
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 08:20:03 +02:00
Gang WenandClaude Opus 4.6 810e34d859 Add transformers 5.x model loading path for Florence2
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>
2026-04-07 08:15:29 +02:00
Gang Wen c8b2ec0b59 fix again 2026-04-06 22:06:50 +02:00
Gang Wen e1dbbca003 added fix 2026-04-06 22:01:39 +02:00
Gang Wen d55bd6acbb Revert "Fix Florence2 config compatibility with transformers 5.x"
This reverts commit 31ab0275de.
2026-04-06 21:34:45 +02:00
Gang WenandClaude Opus 4.6 31ab0275de Fix Florence2 config compatibility with transformers 5.x
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>
2026-04-06 21:26:57 +02:00