-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requesting support in Pipeline using Florence-2 models and tasks #36106
Comments
It should be |
Thanks! Just checked, same issue with the image-test-to-text task.
|
I overlooked this in the morning, Florence config on the hub has an auto-mapping with |
Would that mean the issue is with the models configs? Or currently not in pipeline? |
The problem is in the config, yes Update: I found that we pass an unused argument ( Otherwise the below code worked for me, with a small hack to register AutoProcessor from transformers import AutoConfig, AutoModelForImageTextToText, AutoProcessor, pipeline
from transformers.image_utils import load_image
config = AutoConfig.from_pretrained('microsoft/Florence-2-large', trust_remote_code=True)
config.auto_map['AutoModelForImageTextToText'] = 'microsoft/Florence-2-large--modeling_florence2.Florence2ForConditionalGeneration'
model = AutoModelForImageTextToText.from_pretrained("microsoft/Florence-2-large", config=config, trust_remote_code=True)
processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True)
AutoProcessor.register(type(config), processor)
pipe = pipeline(
'image-text-to-text',
model='microsoft/Florence-2-large',
config=config,
trust_remote_code=True
)
image = load_image("https://www.ilankelman.org/stopsigns/australia.jpg")
print(pipe(images=image, text="What do you see here?")) |
Thanks, I can confirm that I'm also seeing the error with the legacy argument.
Do we have a work around within pipeline to stop this being passed onto the processor? |
Unfortunately no, unless the code itself changes and stops passing |
Issue with pipeline and Florence at the moment, skipping pipeline for the moment on this node. huggingface/transformers#36106
This should be fixed now :), and I opened a PR to fully deprecate the legacy kwarg here: #36307 |
Feature request
Hi!
Currently, microsoft/Florence-2-large-ft or related models cannot be loaded with HF pipeline("image-to-text") as its config is not recognised by AutoModelForVision2Seq.
When attempting to load it, Transformers raises:
“Unrecognised configuration class Florence2Config for this kind of AutoModel: AutoModelForVision2Seq.”
Florence-2 also requires trust_remote_code=True to be passed to the functions.
The current standard method works by loading Florence-2 with AutoModelForCausalLM and AutoProcessor, but this adds another flow if you are already using pipeline, Lora support also works well, having these in the pipeline would making it an amazing addition for its capable tasks.
Thanks!
Model:
https://huggingface.co/microsoft/Florence-2-large
Motivation
Adding support for pipeline with these models would give it another great set of options with tasks while lowering the barrier for entry, as the pipeline is a great feature that simplifies the writing and reusability of code for people. (Like me!)
Thanks again for all the amazing work.
Your contribution
I can test any proposed updates.
The text was updated successfully, but these errors were encountered: