Instructions to use microsoft/Florence-2-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Florence-2-base 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", 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", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("microsoft/Florence-2-base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Florence-2-base 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" # 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", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/microsoft/Florence-2-base
- SGLang
How to use microsoft/Florence-2-base 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" \ --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", "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" \ --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", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use microsoft/Florence-2-base with Docker Model Runner:
docker model run hf.co/microsoft/Florence-2-base
Commit History
-
Remove unnecessary deletion
Verified signaturee10da1a -
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 Nonedc7e692
-
Update README.md
Verified signaturea2f0be7 -
update_readme_example (#3)
Verified signature- update readme example (c1e5c697861fb2c2f9c21ceacd27dfd7cea3868c) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>0f6358c -
add_grounding_example (#2)
Verified signature- add grounding example (b9f04dd36709c6a9c921b97770a440eaad1686ad) - add grounding example (6060dccbb4333867f062c0e8e2ed8eae48ce5755) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>37070d5
-
init_model (#1)
Verified signature- init files (cb51be2b8d7f48f70a621ad0d56eb570ce820543) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>a15cd1f -
initial commit
Verified signaturec3302ad