Instructions to use microsoft/Florence-2-large-ft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Florence-2-large-ft 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-ft", 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-ft", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("microsoft/Florence-2-large-ft", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Florence-2-large-ft 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-ft" # 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-ft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/microsoft/Florence-2-large-ft
- SGLang
How to use microsoft/Florence-2-large-ft 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-ft" \ --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-ft", "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-ft" \ --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-ft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use microsoft/Florence-2-large-ft with Docker Model Runner:
docker model run hf.co/microsoft/Florence-2-large-ft
Commit History
-
Update modeling_florence2.py
Verified signatureAdd GenerationMixin as parent classa80f290
-
update_model_init_fp16 (#20)
Verified signature- update model init with float16 (305356fa763ef4370247f69217541501fbd89b46) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>bb44b80
-
update_ocr_postprocess (#19)
Verified signature- update ocr post-process (e6c93f7995e555ff06e69e653847d40f8dfa9cc8) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>13c0e86
-
Update pipeline tag
Verified signature3112cd2
-
Fix modeling code (typos/bugs) (#10)
Verified signature- Fix modeling code (typos/bugs) (4c4df11a9d1bab0d62988d7102477ebf0f27e309) - Remove unnecessary deletion (9ef4cbea037fe2bbd25dc2ae86c07d355e3448e0) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>45e7f61
-
Fix incorrect bos_token, eos_token, and pad_token ids in config.json (#11)
Verified signature- Fix incorrect bos_token, eos_token, and pad_token ids in config.json (925e20f19d50a6d62ea77d55b8b1fa0f6e693cc9) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>c669c6b
-
Update README.md
Verified signaturef3c2bbf -
add_grounding_example (#3)
Verified signature- add grounding example (1bf75f641b77968fc823f0bc5a70647d4f8b0b08) - update readme example (d1f32dbe929884905eafd0a46fe45c48a3380b93) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>9896a44 -
add_grounding_example (#2)
Verified signature- add grounding example (8c2598ae752723ce1f4f3fb95be58e40c1a3ab1e) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>8743885
-
init_model (#1)
Verified signature- init files (2e2004275ec4904b1ccc2d4f2e493d4515e738e4) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>d5b20a4 -
initial commit
Verified signature880fa77