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
-
Remove unnecessary deletion
Verified signaturee0b8f37 -
Fix modeling code (typos/bugs)
Verified signatureSame as https://huggingface.co/microsoft/Florence-2-large/discussions/12 Two changes: - Fix `Florence2Seq2SeqLMOutput` - Only set `attention_mask` device if inputs_embeds is not None3afa95f
-
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