Image-Text-to-Text
Transformers
TensorBoard
Safetensors
florence2
Generated from Trainer
custom_code
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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ucsahin/Florence-2-large-TableDetection", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("ucsahin/Florence-2-large-TableDetection", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- 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
Upload 3 files
Browse files- modeling_florence2.py +1 -4
modeling_florence2.py
CHANGED
|
@@ -2289,8 +2289,6 @@ class Florence2Seq2SeqLMOutput(ModelOutput):
|
|
| 2289 |
image_hidden_states of the model produced by the vision encoder
|
| 2290 |
"""
|
| 2291 |
|
| 2292 |
-
loss: torch.FloatTensor = None
|
| 2293 |
-
logits: torch.FloatTensor = None
|
| 2294 |
last_hidden_state: torch.FloatTensor = None
|
| 2295 |
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None
|
| 2296 |
decoder_hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
|
@@ -2299,7 +2297,6 @@ class Florence2Seq2SeqLMOutput(ModelOutput):
|
|
| 2299 |
encoder_last_hidden_state: Optional[torch.FloatTensor] = None
|
| 2300 |
encoder_hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
| 2301 |
encoder_attentions: Optional[Tuple[torch.FloatTensor, ...]] = None
|
| 2302 |
-
image_hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
| 2303 |
|
| 2304 |
|
| 2305 |
FLORENCE2_START_DOCSTRING = r"""
|
|
@@ -2530,7 +2527,7 @@ class Florence2ForConditionalGeneration(Florence2PreTrainedModel):
|
|
| 2530 |
def __init__(self, config: Florence2Config):
|
| 2531 |
super().__init__(config)
|
| 2532 |
assert config.vision_config.model_type == 'davit', 'only DaViT is supported for now'
|
| 2533 |
-
|
| 2534 |
self.vision_tower = DaViT.from_config(config=config.vision_config)
|
| 2535 |
# remove unused layers
|
| 2536 |
del self.vision_tower.head
|
|
|
|
| 2289 |
image_hidden_states of the model produced by the vision encoder
|
| 2290 |
"""
|
| 2291 |
|
|
|
|
|
|
|
| 2292 |
last_hidden_state: torch.FloatTensor = None
|
| 2293 |
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None
|
| 2294 |
decoder_hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
|
|
|
| 2297 |
encoder_last_hidden_state: Optional[torch.FloatTensor] = None
|
| 2298 |
encoder_hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None
|
| 2299 |
encoder_attentions: Optional[Tuple[torch.FloatTensor, ...]] = None
|
|
|
|
| 2300 |
|
| 2301 |
|
| 2302 |
FLORENCE2_START_DOCSTRING = r"""
|
|
|
|
| 2527 |
def __init__(self, config: Florence2Config):
|
| 2528 |
super().__init__(config)
|
| 2529 |
assert config.vision_config.model_type == 'davit', 'only DaViT is supported for now'
|
| 2530 |
+
del config.vision_config.model_type
|
| 2531 |
self.vision_tower = DaViT.from_config(config=config.vision_config)
|
| 2532 |
# remove unused layers
|
| 2533 |
del self.vision_tower.head
|