Run this model with HF Jobs
Run microsoft/Florence-2-large on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/microsoft/Florence-2-large. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/microsoft/Florence-2-large on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/microsoft/Florence-2-large. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/microsoft/Florence-2-large. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use microsoft/Florence-2-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Florence-2-large with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="microsoft/Florence-2-large", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Florence-2-large with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/Florence-2-large" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Florence-2-large", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/microsoft/Florence-2-large
- SGLang
How to use microsoft/Florence-2-large with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "microsoft/Florence-2-large" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Florence-2-large", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "microsoft/Florence-2-large" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Florence-2-large", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use microsoft/Florence-2-large with Docker Model Runner:
docker model run hf.co/microsoft/Florence-2-large
doesn't work well with transformers >= 4.52.1
lib/python3.12/site-packages/torch/nn/modules/module.py", line 1940, in __getattr__
raise AttributeError(
AttributeError: 'DaViT' object has no attribute '_initialize_weights'
No such issue when transformers 4.51.3
But, I get this issue when using with transformers 4.52.1 and higher (was using 4.52.3)
I can confirm 4.51.3 has no issues
It's broken above 4.49...Please fix this otherwise I'll be forced to no longer use these great models...
Hi, I’m facing an issue while trying to load the DaViT model.
When I instantiate the model, I get the following error:
AttributeError: 'DaViT' object has no attribute '_initialize_weights'
Please define the _initialize_weights function in the DaViT class, or remove the call if it’s not needed (especially if the model is pretrained and doesn’t require reinitialization).
Kindly guide me on this as soon as possible (ASAP).
Thanks in advance!
gopi123456789987654321
Just downgrade transformers
That’s what I did
kimsia
it is working now
Thank you very much
It's broken above 4.49...Please fix this otherwise I'll be forced to no longer use these great models...
Not correct. Works with 4.51.3
AttributeError: 'DaViT' object has no attribute '_initialize_weights'
My investigation of this problem showed that the problem is not only in transformers, but in the incompatibility of triton and xformers versions.
In the end, I had to manually remove folders torch, torchvision, torchaudio. Install torch==2.7.1 for cu126, transformers==4.51.1, triton==3.2.0+gited43d228, xformers==0.0.31
And only after that the problems disappeared.
Can we update the model card of the dependencies used and their versions?
In the config.json there is a line: "transformers_version": "4.41.0.dev0", which i,of course,the minimum version.It would be nice if there was also a line for the Maximum supported version. Maybe: "transformers_max: "4.51.3"
I ran into the issue that the maximum version for Florence2 was lower then the minimum version for gemma3, so I built two instances separately to work on them. I have never tried to load two transformers versions at once in the same app. I'm not sure it has the code to be called by version number without constantly replacing itself.