Views
No views yet
modeling_florence2.py to allow the model to load and generate text out-of-the-box using newer versions of the Hugging Face transformers library (specifically version 4.42.0 up to the latest 4.57.x) without triggering common errors._supports_sdpa AttributeError Fix:
Prevents model load crashes on newer transformers versions that inspect attention properties before the nested language model is initialized.NoneType / shape TypeError Fix:
Resolves the crash during generation: TypeError: expected Tensor as element 0 in argument 0, but got NoneType (or 'NoneType' object has no attribute 'shape'). This happens because modern transformers caches initialize with empty placeholders (None) which the original custom code attempted to perform .shape and torch.cat on. The patch adds checks to bypass empty cache slots.transformers code:1from transformers import AutoModelForCausalLM, AutoProcessor
2
3model = AutoModelForCausalLM.from_pretrained(
4 "topguy/Florence-2-base-ft-compat",
5 trust_remote_code=True
6)
7processor = AutoProcessor.from_pretrained(
8 "topguy/Florence-2-base-ft-compat",
9 trust_remote_code=True
10)