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
-
Upload 4 files
Verified signature9f79869
-
add confidence scores for `od` and `description_with_bboxes` tasks (#25)
Verified signature- add confidence scores for `od` and `description_with_bboxes` tasks (15bd11834572457e1e8e8fec7f25c83283902db2) Co-authored-by: Fatih C. Akyon <fcakyon@users.noreply.huggingface.co>5ca5edf -
Fix invalid escape sequences (#20)
Verified signature- Fix invalid escape sequences (aea5f4f0449c34e1ccfedc459b7d1640d2455059) Co-authored-by: Junpei Kawamoto <jkawamoto@users.noreply.huggingface.co>a495aed -
Fix the error "only DaViT is supported for now" appears whenloading the fine-tuned model (#31)
Verified signature- Fix the error "only DaViT is supported for now" appears whenloading the fine-tuned model (9260a487de5b466e6cea5519001154ff05144929) Co-authored-by: Fatih C. Akyon <fcakyon@users.noreply.huggingface.co>fe9219b -
Fix: resize_token_embeddings's Interface for transformers v4.49.0 (#26)
Verified signature- Fix: resize_token_embeddings's Interface for transformers v4.49.0 (9990a98b2725653cba66babb82fbd007ae958b95) Co-authored-by: YEN-FU LIN <gar231@users.noreply.huggingface.co>2f6bee8 -
Fix weight init, deprecation warnings, safetensors (#27)
Verified signature- Update modeling code and weights (9a303c20e479b3e899a8262364920a58227458f8) - Add one more file (c2d78d1e36292674195414029d0d0c1a721c53e1) - Update tied weights keys (bef74d7de9a4f1275b0c6e517b80afee13018e5c) - Tie weights correctly and update weights (1e8c51ff43b3851d36c8a21f688ad903ebfe4f0a) - Fix dtype (386f84a8872b44814ea429c0187e0b7406260d94)1896e7c
-
Inherit from GenerationMixin (#22)
Verified signature- Add GenerationMixin as parent class (2a2d45ec4da455d12cd7eba75c8a0f006ece2d15) Co-authored-by: Fatih C. Akyon <fcakyon@users.noreply.huggingface.co>ceaf371
-
update_model_init_fp16 (#12)
Verified signature- update model init with float16 (8c55fe1ada8186cc1d35785756e0e63ef1e6827a) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>ee1f1f1
-
update_ocr_postprocess (#11)
Verified signature- update ocr post-process (5fe6a7907de0bc310f141c5f63a83f527efbcf68) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>09eb282
-
Update pipeline tag
Verified signature53f3fb4
-
Fix modeling code (typos/bugs) (#5)
Verified signature- Fix modeling code (typos/bugs) (dc7e6928b12c148726d4cee0ff011cfe2cebddea) - Remove unnecessary deletion (e10da1a2e5fdb01c16941174bcde29689fb53c0b) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>4fab3c0
-
Fix incorrect bos_token, eos_token, and pad_token ids in config.json (#6)
Verified signature- Fix incorrect bos_token, eos_token, and pad_token ids in config.json (75e922a51facc3440dcb168ac029d19a55ee16ab) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>78e1dd4
-
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