Instructions to use theIndividual/Florence-2-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use theIndividual/Florence-2-large with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("image-to-text", model="theIndividual/Florence-2-large", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("theIndividual/Florence-2-large", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("theIndividual/Florence-2-large", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Pedro Cavalcanti commited on
Commit ·
f52cc27
1
Parent(s): 2fd6c2c
changing modeling file
Browse files- modeling_florence2.py +4 -1
modeling_florence2.py
CHANGED
|
@@ -2289,6 +2289,7 @@ class Florence2Seq2SeqLMOutput(ModelOutput):
|
|
| 2289 |
image_hidden_states of the model produced by the vision encoder
|
| 2290 |
"""
|
| 2291 |
|
|
|
|
| 2292 |
last_hidden_state: torch.FloatTensor = None
|
| 2293 |
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None
|
| 2294 |
decoder_hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
|
@@ -2757,6 +2758,8 @@ class Florence2ForConditionalGeneration(Florence2PreTrainedModel):
|
|
| 2757 |
output = (logits,) + outputs[1:]
|
| 2758 |
return (loss,) + output if loss is not None else output
|
| 2759 |
|
|
|
|
|
|
|
| 2760 |
return Florence2Seq2SeqLMOutput(
|
| 2761 |
loss=loss,
|
| 2762 |
logits=logits,
|
|
@@ -2838,4 +2841,4 @@ class Florence2ForConditionalGeneration(Florence2PreTrainedModel):
|
|
| 2838 |
return self.language_model.shift_tokens_right(labels)
|
| 2839 |
|
| 2840 |
def _reorder_cache(self, *args, **kwargs):
|
| 2841 |
-
return self.language_model._reorder_cache(*args, **kwargs)
|
|
|
|
| 2289 |
image_hidden_states of the model produced by the vision encoder
|
| 2290 |
"""
|
| 2291 |
|
| 2292 |
+
loss: torch.FloatTensor = None
|
| 2293 |
last_hidden_state: torch.FloatTensor = None
|
| 2294 |
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None
|
| 2295 |
decoder_hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
|
|
|
| 2758 |
output = (logits,) + outputs[1:]
|
| 2759 |
return (loss,) + output if loss is not None else output
|
| 2760 |
|
| 2761 |
+
print(loss)
|
| 2762 |
+
|
| 2763 |
return Florence2Seq2SeqLMOutput(
|
| 2764 |
loss=loss,
|
| 2765 |
logits=logits,
|
|
|
|
| 2841 |
return self.language_model.shift_tokens_right(labels)
|
| 2842 |
|
| 2843 |
def _reorder_cache(self, *args, **kwargs):
|
| 2844 |
+
return self.language_model._reorder_cache(*args, **kwargs)
|