Instructions to use microsoft/Florence-2-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Florence-2-large 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", 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", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Florence-2-large 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" # 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", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/microsoft/Florence-2-large
- SGLang
How to use microsoft/Florence-2-large 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" \ --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", "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" \ --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", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use microsoft/Florence-2-large with Docker Model Runner:
docker model run hf.co/microsoft/Florence-2-large
Commit History
-
Update configuration_florence2.py (#62)
Verified signature- Update configuration_florence2.py (447e712b7902f4ad5279f9906bc16d81c9a58856) Co-authored-by: zbing <zbing@users.noreply.huggingface.co>21a599d -
Fix: resize_token_embeddings's Interface for transformers v4.49.0 (#97)
Verified signature- Update modeling_florence2.py (e1c1f560ff2f4429276453ccb08f0df44819ec06) Co-authored-by: YEN-FU LIN <gar231@users.noreply.huggingface.co>6e29045 -
Fix weight init, deprecation warnings, safetensors (#103)
Verified signature- initial commit (32734202eff48e0776b6dc0091ef305c92edf74d) - Correct dtype for weights (c8ec27656c1359454cd7e9c13133398bb4cd1424) - Move weight init correctly (24d011b97e79ee7f3af54a04d5d656e9988ee5f3) - Tie weights correctly (6813a8d0804dd7df783ebf376c8fc7fe67b0d5d1)a935c70
-
initial tuned 4k context length model (#84)
Verified signature- add 4k context length model (43013a8f5eccffac1f83ec7d00e94b9ecb218380) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>00d2f15
-
add_confidence_score (#56)
Verified signature- add confidence score parsing (2ce7cd7837dfc8d93bf1d77dae95669ef1bcf0b3)f0acedb
-
Inherit from GenerationMixin (#80)
Verified signature- Add GenerationMixin as parent class (c719442dd7d237edafe787824ebe245dcfa997d4) Co-authored-by: Marvin Gazibarić <Link161@users.noreply.huggingface.co>f928440
-
Fix invalid escape sequences (#65)
Verified signature- Fix invalid escape sequences (e66fed94dc63ee1785716366c4e51aeb05a6ba25) Co-authored-by: Junpei Kawamoto <jkawamoto@users.noreply.huggingface.co>39ddb41
-
update_model_init_fp16 (#53)
Verified signature- update model init with float16 (93d5b247d87e5e0afeafe5b49c4a796aa5ba9e7c) - update model init with float16 (bab1b3cbc340fac15205568422af11476c232442) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>6bf1792
-
update_ocr_postprocess (#52)
Verified signature- update ocr post-process (f2eb43e7c5267c1bdf4053f1478b29fc875703c8) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>df93020
-
Update pipeline tag
Verified signature15aa04e
-
Fix modeling code (typos/bugs) (#12)
Verified signature- Fix modeling code (typos/bugs) (5554f70f9adfefb797a9965c11e8bf539eeca585) - Remove unnecessary deletion (f0a0996b38848cb40f47db06d4735652bbd7af4d) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>484465f
-
Fix runon lines (#16)
Verified signature- Fix runon lines (e83cf618af698c7037d277e6f595ffe536d7ea17) Co-authored-by: Marcin Miłkowski <milekpl@users.noreply.huggingface.co>aec3bc5 -
Fix incorrect bos_token, eos_token, and pad_token ids in config.json (#17)
Verified signature- Update config.json (74644d78c52c8a0b983573f5ef90dd700d271832) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>8651614
-
add_caption_grounding (#23)
Verified signature- add caption + grounding notebook (27b374bc62cdb218b9e6e6db0130e0720fbb48a5) - add caption + grounding notebook (9f4863026e60e929758b659fa5661a4345b56eac) - add caption + grounding notebook (031fc99d9204634daa6574c8cfa64dbc2cbccf94) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>ef29c9b
-
Update README.md
Verified signature6e0aa88 -
update_readme_example (#5)
Verified signature- update readme example (5796686028011df06a7c4a73acd3b377c0844b06) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>0f7c938 -
add_grounding_example (#3)
Verified signature- add grounding example (10934606d2fcd32b4359d2fdabbb4aa84052b1ef) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>9509157 -
add_grounding_example (#2)
Verified signature- add grounding example (1911d59bbc7bb437c1c24e1f0f93eaa438a212f7) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>0c7be59
-
add_model (#1)
Verified signature- init files (2a83a12b643b0cd18fde2bee55c8a1bc43a4949d) Co-authored-by: Haiping Wu <haipingwu@users.noreply.huggingface.co>33ee8e1 -
initial commit
Verified signature77dfafb