Instructions to use ducviet00/Florence-2-large-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ducviet00/Florence-2-large-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ducviet00/Florence-2-large-hf")# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("ducviet00/Florence-2-large-hf") model = AutoModelForImageTextToText.from_pretrained("ducviet00/Florence-2-large-hf") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ducviet00/Florence-2-large-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ducviet00/Florence-2-large-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ducviet00/Florence-2-large-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ducviet00/Florence-2-large-hf
- SGLang
How to use ducviet00/Florence-2-large-hf 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 "ducviet00/Florence-2-large-hf" \ --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": "ducviet00/Florence-2-large-hf", "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 "ducviet00/Florence-2-large-hf" \ --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": "ducviet00/Florence-2-large-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ducviet00/Florence-2-large-hf with Docker Model Runner:
docker model run hf.co/ducviet00/Florence-2-large-hf
How to convert non finetuned florence2 model weights to this new native format?
Thanks for the native implementation! @ducviet00 @sayakpaul @davidlittlefield
The finetuned variants of Florence2 models (microsoft/Florence-2-large-ft [30k downloads] and microsoft/Florence-2-base-ft [49k downloads]) perform good on few academic benchmarks (shorter overfitted captions and phrases) but in reality non-finetuned models (microsoft/Florence-2-large [580k downloads] and microsoft/Florence-2-base [820K downloads]) perform better (longer, more diverse, underfitted generations). You can confirm this by their monthly download counts.
Why do you only support these underperforming finetuned variants in the native Florence2 implementation? ๐ค
Can you guide me on how I can convert other Florence2 weights to the new supported format? ๐๐ป
Bests
Sorry, I missed your notification earlier.
Hereโs the script you can use to convert the model:
https://github.com/huggingface/transformers/tree/main/src/transformers/models/florence2
Example usage:
python convert_florence2_original_pytorch_to_hf.py \
--hf_model_id microsoft/Florence-2-large \
--pytorch_dump_folder_path florence2-large \
--output_hub_path ducviet00/Florence-2-large-hf