Instructions to use microsoft/Florence-2-base-ft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Florence-2-base-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-base-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-base-ft", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("microsoft/Florence-2-base-ft", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Florence-2-base-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-base-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-base-ft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/microsoft/Florence-2-base-ft
- SGLang
How to use microsoft/Florence-2-base-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-base-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-base-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-base-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-base-ft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use microsoft/Florence-2-base-ft with Docker Model Runner:
docker model run hf.co/microsoft/Florence-2-base-ft
Commit History
-
Fix invalid escape sequences
Verified signatureThis PR fixes this warning: `processing_florence2.py:499: SyntaxWarning: invalid escape sequence '\d'`. This warning occurs because a docstring contains unescaped backslashes. This PR modifies the docstring so that it is defined as a raw string and backslashes don’t make escape sequences.1211844
-
update_model_init_fp16 (#20)
Verified signature- update model init with float16 (af7d34c7aa7c09bf97fc3d746bbb465d1e9d30e5) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>9803f52
-
update_ocr_postprocess (#19)
Verified signature- update ocr post-process (f760c1169c8d20836a36d138b22050017066e6b2) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>f2be9b1
-
Update pipeline tag
Verified signatureace966b
-
Fix modeling code (typos/bugs) (#6)
Verified signature- Fix modeling code (typos/bugs) (3afa95f29c831f1ea138d5d02e181fac2463e1e9) - Remove unnecessary deletion (e0b8f375661041228a6431c950adac1a5c539b98) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>56dfc91
-
Fix incorrect bos_token, eos_token, and pad_token ids in config.json (#7)
Verified signature- Fix incorrect bos_token, eos_token, and pad_token ids in config.json (6c7d1cb5e484d7de0d1db45285db99e40e1457ff) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>9cef882
-
Update README.md
Verified signaturee7a5acc -
update_readme_example (#3)
Verified signature- update readme example (5ce8030ab7f9b5c0d7c8b28f65ec68aafc818235) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>e4e3ff8 -
add_grounding_example (#2)
Verified signature- add grounding example (f82f629ff636e04cf71bd9f0d7e7935ab7f1769f) - add grounding example (de196341bbb39827166ba5de1e6e4317546222e5) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>5117f5a
-
init_model (#1)
Verified signature- init files (03b3cf7cc69aea83903f55064265ab05e540e4df) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>494b983 -
initial commit
Verified signature17b32c0