Downloads · 30 days
8
5% of all-time downloads
Rusted-Gold/Florence-2-large-ft-Transformers-Fix
Florence-2-large-ft-Transformers-Fix is a machine learning model from Rusted-Gold. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This is the Florence-2-large-ft (Fine-Tuned) model from Microsoft Corporation, made compatible with transformers==4.57.3.
Downloads · 30 days
8
5% of all-time downloads
All-time downloads
170
Public
Parameters
770M
3.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.bin1.5 GB · 50%
From the Hugging Face model README
This is the Florence-2-large-ft (Fine-Tuned) model from Microsoft Corporation, made compatible with transformers==4.57.3.
Original License: MIT License
Original Copyright: © 2024 Microsoft Corporation
This modified version maintains the original MIT license and respects all original copyright notices. All original code, model weights, and fine-tuning remain the intellectual property of Microsoft Corporation.
Fixed compatibility issues with transformers==4.57.3 where AttributeError: 'NoneType' object has no attribute 'shape' occurred during model inference and generation.
In transformers 4.57.3, the past_key_values structure can contain None elements at various nesting levels, particularly during early generation stages. The original code only checked for top-level None but not nested None values.
Florence2Attention and Florence2FlashAttention2)modeling_florence2.pypast_key_value[0] is not None check before accessing .shape[2]# Before
if (is_cross_attention and past_key_value is not None
and past_key_value[0].shape[2] == key_value_states.shape[1]):
# After
if (is_cross_attention and past_key_value is not None
and past_key_value[0] is not None
and past_key_value[0].shape[2] == key_value_states.shape[1]):
modeling_florence2.pypast_key_value[0] is not None check before shape access# Before
if past_key_value is not None:
kv_seq_len += past_key_value[0].shape[-2]
# After
if past_key_value is not None and past_key_value[0] is not None:
kv_seq_len += past_key_value[0].shape[-2]
modeling_florence2.pypast_key_values access in try-except blocks with fallbacks# Before
past_length = past_key_values[0][0].shape[2]
# After
try:
past_length = past_key_values[0][0].shape[2]
except (AttributeError, TypeError, IndexError):
past_length = 0
modeling_florence2.py - Multiple locations for robustness✅ Fully backward compatible with older transformers versions
✅ Forward compatible with future transformers versions using DynamicCache
from transformers import AutoModel, AutoProcessor
import torch
# Load the fine-tuned model
model = AutoModel.from_pretrained(
"path/to/Florence-2-large-ft",
trust_remote_code=True
)
processor = AutoProcessor.from_pretrained(
"path/to/Florence-2-large-ft"
)
# Generate with compatibility fixes
model.eval()
with torch.no_grad():
inputs = processor(text="Analyze this image", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=75)
This is a fine-tuned version optimized for specific tasks. Refer to original Microsoft repository for fine-tuning details and training procedures.
Test the following scenarios to ensure compatibility:
Version: 1.0 (Transformers 4.57.3 Compatible)
Last Updated: March 2026
Status: Production Ready