Instructions to use ucsahin/Florence-2-large-TableDetection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ucsahin/Florence-2-large-TableDetection with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ucsahin/Florence-2-large-TableDetection", trust_remote_code=True)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("ucsahin/Florence-2-large-TableDetection", trust_remote_code=True) model = AutoModelForImageTextToText.from_pretrained("ucsahin/Florence-2-large-TableDetection", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ucsahin/Florence-2-large-TableDetection with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ucsahin/Florence-2-large-TableDetection" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ucsahin/Florence-2-large-TableDetection", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ucsahin/Florence-2-large-TableDetection
- SGLang
How to use ucsahin/Florence-2-large-TableDetection 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 "ucsahin/Florence-2-large-TableDetection" \ --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": "ucsahin/Florence-2-large-TableDetection", "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 "ucsahin/Florence-2-large-TableDetection" \ --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": "ucsahin/Florence-2-large-TableDetection", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ucsahin/Florence-2-large-TableDetection with Docker Model Runner:
docker model run hf.co/ucsahin/Florence-2-large-TableDetection
TypeError need help
when i was fine-tuning the Florence-2-base-FT, i meet one problem, shows that:
Traceback (most recent call last):
File "/home/Florence-2/fine_turning.py", line 175, in
trainer.train()
File "/opt/conda/lib/python3.10/site-packages/transformers/trainer.py", line 1885, in train
return inner_training_loop(
File "/opt/conda/lib/python3.10/site-packages/transformers/trainer.py", line 2216, in _inner_training_loop
tr_loss_step = self.training_step(model, inputs)
File "/opt/conda/lib/python3.10/site-packages/transformers/trainer.py", line 3238, in training_step
loss = self.compute_loss(model, inputs)
File "/opt/conda/lib/python3.10/site-packages/transformers/trainer.py", line 3264, in compute_loss
outputs = model(**inputs)
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/.cache/huggingface/modules/transformers_modules/modeling_florence2.py", line 2760, in forward
return Florence2Seq2SeqLMOutput(
TypeError: Florence2Seq2SeqLMOutput.init() got an unexpected keyword argument 'loss'
can you help me, thx
Did you try to load the model with the PR fix mentioned in https://huggingface.co/blog/finetune-florence2?
Like this:
model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-base-ft", trust_remote_code=True, revision='refs/pr/6').to(device)
processor = AutoProcessor.from_pretrained("microsoft/Florence-2-base-ft", trust_remote_code=True, revision='refs/pr/6')
The problem has been solved, thanks for your suggestion~
This issue appears to be a code bug that has been fixed by the author: https://huggingface.co/microsoft/Florence-2-large/discussions/12#66752ee0ec54ee155826d156

