Vision-language model
Self-host Florence-2: 1.55GB of weights that does detection, OCR and dense captioning
A vision foundation model with 0.77B parameters and 1.55GB of fp16 weights, switching between detection, segmentation, OCR and captioning with a single task token. From $0.193/GPU-hr on an RTX 3090 24GB, metered per second.
Florence · self-hosted
The name Florence covers two different things. Microsoft's 2021 paper "Florence: A New Foundation Model for Computer Vision" describes a closed vision foundation model most people only ever touched through Azure's image analysis service. What you can actually download, ship and modify is its open successor, Florence-2 (technical report arXiv 2311.06242), MIT licensed, weights on Hugging Face. So when people search for running Florence locally, Florence-2 is almost always what they mean.
The surprising part is how small it is. Florence-2-large is 0.77B parameters and its model.safetensors is 1.55GB; the base version is 0.23B and 463MB. At that size, trained on FLD-5B (5.4 billion annotations over 126 million images), one model handles captioning, detailed captioning, object detection, dense region captioning, phrase grounding, open-vocabulary detection, referring expression segmentation, OCR and OCR with regions. You switch between them not by writing a prompt but by feeding a task token — <OD>, <OCR_WITH_REGION>, <CAPTION_TO_PHRASE_GROUNDING> — as the input.
The architecture is a DaViT vision tower plus a BART-style encoder-decoder text tower, and that shapes how you deploy it. It is not decoder-only, so the usual vLLM fast path does not apply — vLLM lists Florence2ForConditionalGeneration under its bart-plugin rather than as a native architecture. But because the model is tiny, you can spend the entire card on batch size and brute-force the throughput. What costs money here is labelling volume and fine-tuning hours, never VRAM.
01 —
Variants and VRAM
Use the florence-community org — it hosts the official transformers-converted checkpoints
| Version | Parameters | VRAM | Context | Notes |
|---|---|---|---|---|
| florence-community/Florence-2-large | 0.77B | 1.55GB fp16 weights / under 1GB in bitsandbytes 4-bit | 4096 (text tower) | The default pick. Zero-shot detection, dense region captioning and OCR are all a clear step above base, and it is by far the most downloaded of the four checkpoints. |
| florence-community/Florence-2-base | 0.23B | 463MB fp16 weights | 4096 (text tower) | For chewing through million-image libraries, or squeezing onto CPU and edge devices — the community has already shipped ONNX, CoreML and ExecuTorch ports. |
| florence-community/Florence-2-large-ft | 0.77B | 1.55GB fp16 weights | 4096 (text tower) | Further fine-tuned on a collection of downstream tasks. Better benchmark numbers, weaker zero-shot generalisation than plain large — run both on your own data before choosing. |
| florence-community/Florence-2-base-ft | 0.23B | 463MB fp16 weights | 4096 (text tower) | The fine-tuned small model, for narrow fixed pipelines that only ever need one or two task tokens. |
| Florence-VL 3B / 8B (jiuhai/florence-vl-*) | listed as 5B / 9B on HF | ~10GB / ~18GB in bf16 (estimated from listed parameter counts) | inherited from the base LLM | The follow-on line: Florence-2 used as a vision encoder feeding an LLM for conversational VQA. Go here if you need chat; stay on Florence-2 if you need boxes and coordinates. |
02 —
Which card to rent
With 1.55GB of weights, VRAM is not the constraint — throughput and GPU-hours are
Single-GPU inference and day-to-day batch labelling
RTX 3090 24GB$0.193/GPU-hr
The cheapest Ampere card on the fleet, with full fp16 tensor cores — load 1.55GB of weights and the remaining 20GB is pure batch headroom.
High-throughput pipeline captioning a million-image library in one pass
RTX 4090 24GB$0.540/GPU-hr
Same 24GB, meaningfully more images per hour — and when billing is per second, the time you save is the money you save.
Domain fine-tuning with the vision tower frozen (DocVQA, receipts, UI screenshots)
A100 PCIE 80GB$0.824/GPU-hr
The official recipe fits batch size 6 in 40GB with the encoder frozen; 80GB lets you scale the batch up without rewriting your LR schedule.
Full fine-tune with the vision tower unfrozen, reproducing the official 8-GPU run
H100 SXM 80GB ×8$3.582/GPU-hr
The published batch-64, 7-epoch, 70-minute configuration transplanted as-is — up to 14 GPUs per node, and 8 of them needs no quota request.
03 —
From boot to your first bounding box
Four steps, and trust_remote_code never appears
- 01
Boot a PyTorch instance and install the right stack
Start from a prebuilt PyTorch image and come in over SSH, Jupyter or the web terminal. Florence-2 now lives in the transformers main branch as Florence2ForConditionalGeneration and Florence2Processor, so trust_remote_code=True is no longer part of the picture.
pip install -U transformers accelerate timm einops pillow - 02
Pull the officially converted weights
Use the florence-community org: base, base-ft, large and large-ft all live there, with configs converted under transformers 4.56.1. The original microsoft/ repo ships the 2024-era modeling_florence2.py custom code, which keeps fighting with newer transformers releases — no reason to walk into that again.
hf download florence-community/Florence-2-large --local-dir /workspace/florence2-large - 03
Run your first image with a task token
The processor resizes every image to a fixed 768×768, the task token decides what the model does, and generation defaults to num_beams=3 with max_new_tokens typically set to 1024. What comes back is a string containing quantised location tokens from <loc_0> to <loc_999> — you must pass it through post_process_generation together with the original image_size to recover pixel coordinates. Parsing the raw string as JSON will give you wrong boxes.
python -c "from transformers import pipeline; p = pipeline('image-text-to-text', model='florence-community/Florence-2-large', device=0); print(p('demo.jpg', text='<OD>'))" - 04
Shrink it, or go the other way and scale it
To go smaller, the transformers docs give a ready bitsandbytes example — BitsAndBytesConfig(load_in_4bit=True) drops the weights under 1GB. To go bigger, do the opposite: spend the whole card on batch size and pad your images toward 768 on the long edge first to avoid pointless rescaling. Stop the instance when the run finishes; compute billing stops immediately, and only storage keeps accruing until you destroy it.
pip install bitsandbytes
What this actually costs
Start with the expensive end: reproducing Hugging Face's DocVQA fine-tune with the vision tower unfrozen, batch 64, 7 epochs, which they ran on 8 H100s in 70 minutes. On NexGPU that is 8 × $3.582 = $28.656/hr, and 70 minutes means 28.656 × 70 ÷ 60 = $33.43 for the whole run. If budget matters more than wall clock, take their frozen-encoder, batch-6 route instead: a single A100 PCIE 80GB at $0.824/GPU-hr costs 0.824 × 12 = $9.89 even if it drags out to 12 hours. Inference is almost free by comparison — Florence-2-large is 1.55GB of fp16 weights, so an RTX 3090 24GB at $0.193/GPU-hr running a captioning service around the clock is 0.193 × 24 = $4.63/day, and stepping up to an RTX 4090 24GB is still only 0.540 × 24 = $12.96/day. Keep 20GB of dataset plus checkpoints for three days and that is 20 × $0.414 × 3 ÷ 30 = $0.83. Everything is metered per second and priced per hour, with no minimum, no setup fee and no quota request; compute billing stops when the instance stops, while storage runs until you destroy it.
04 —
FAQ
How much VRAM does Florence-2 actually need?
Can I serve Florence-2 with vLLM?
Why won't microsoft/Florence-2-large load on my machine?
Is Florence-2's OCR good enough to replace a dedicated OCR engine?
How many GPUs do I need to fine-tune Florence-2?
Is Florence obsolete? Is there something newer?
More in Multimodal vision models
Start building on NexGPU
Enterprise R&D team or solo developer — either way, your first job can be running in minutes.
Sign up to browse live network pricing. No payment method required.
