Image-Text-to-Text
Transformers
ONNX
Safetensors
Transformers.js
florence2
vision
text-generation
text2text-generation
image-to-text
custom_code
Instructions to use Xenova/tiny-random-Florence2ForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Xenova/tiny-random-Florence2ForConditionalGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Xenova/tiny-random-Florence2ForConditionalGeneration", trust_remote_code=True)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("Xenova/tiny-random-Florence2ForConditionalGeneration", trust_remote_code=True) model = AutoModelForImageTextToText.from_pretrained("Xenova/tiny-random-Florence2ForConditionalGeneration", trust_remote_code=True) - Transformers.js
How to use Xenova/tiny-random-Florence2ForConditionalGeneration with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-text-to-text', 'Xenova/tiny-random-Florence2ForConditionalGeneration'); - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Xenova/tiny-random-Florence2ForConditionalGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Xenova/tiny-random-Florence2ForConditionalGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Xenova/tiny-random-Florence2ForConditionalGeneration", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Xenova/tiny-random-Florence2ForConditionalGeneration
- SGLang
How to use Xenova/tiny-random-Florence2ForConditionalGeneration 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 "Xenova/tiny-random-Florence2ForConditionalGeneration" \ --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": "Xenova/tiny-random-Florence2ForConditionalGeneration", "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 "Xenova/tiny-random-Florence2ForConditionalGeneration" \ --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": "Xenova/tiny-random-Florence2ForConditionalGeneration", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Xenova/tiny-random-Florence2ForConditionalGeneration with Docker Model Runner:
docker model run hf.co/Xenova/tiny-random-Florence2ForConditionalGeneration
Update preprocessor_config.json
Browse files- preprocessor_config.json +37 -1
preprocessor_config.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
| 17 |
"input_data_format"
|
| 18 |
],
|
| 19 |
"auto_map": {
|
| 20 |
-
"AutoProcessor": "
|
| 21 |
},
|
| 22 |
"crop_size": {
|
| 23 |
"height": 768,
|
|
@@ -46,5 +46,41 @@
|
|
| 46 |
"size": {
|
| 47 |
"height": 768,
|
| 48 |
"width": 768
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
}
|
| 50 |
}
|
|
|
|
| 17 |
"input_data_format"
|
| 18 |
],
|
| 19 |
"auto_map": {
|
| 20 |
+
"AutoProcessor": "processing_florence2.Florence2Processor"
|
| 21 |
},
|
| 22 |
"crop_size": {
|
| 23 |
"height": 768,
|
|
|
|
| 46 |
"size": {
|
| 47 |
"height": 768,
|
| 48 |
"width": 768
|
| 49 |
+
},
|
| 50 |
+
"tasks_answer_post_processing_type": {
|
| 51 |
+
"<OCR>": "pure_text",
|
| 52 |
+
"<OCR_WITH_REGION>": "ocr",
|
| 53 |
+
"<CAPTION>": "pure_text",
|
| 54 |
+
"<DETAILED_CAPTION>": "pure_text",
|
| 55 |
+
"<MORE_DETAILED_CAPTION>": "pure_text",
|
| 56 |
+
"<OD>": "description_with_bboxes",
|
| 57 |
+
"<DENSE_REGION_CAPTION>": "description_with_bboxes",
|
| 58 |
+
"<CAPTION_TO_PHRASE_GROUNDING>": "phrase_grounding",
|
| 59 |
+
"<REFERRING_EXPRESSION_SEGMENTATION>": "polygons",
|
| 60 |
+
"<REGION_TO_SEGMENTATION>": "polygons",
|
| 61 |
+
"<OPEN_VOCABULARY_DETECTION>": "description_with_bboxes_or_polygons",
|
| 62 |
+
"<REGION_TO_CATEGORY>": "pure_text",
|
| 63 |
+
"<REGION_TO_DESCRIPTION>": "pure_text",
|
| 64 |
+
"<REGION_TO_OCR>": "pure_text",
|
| 65 |
+
"<REGION_PROPOSAL>": "bboxes"
|
| 66 |
+
},
|
| 67 |
+
"task_prompts_without_inputs": {
|
| 68 |
+
"<OCR>": "What is the text in the image?",
|
| 69 |
+
"<OCR_WITH_REGION>": "What is the text in the image, with regions?",
|
| 70 |
+
"<CAPTION>": "What does the image describe?",
|
| 71 |
+
"<DETAILED_CAPTION>": "Describe in detail what is shown in the image.",
|
| 72 |
+
"<MORE_DETAILED_CAPTION>": "Describe with a paragraph what is shown in the image.",
|
| 73 |
+
"<OD>": "Locate the objects with category name in the image.",
|
| 74 |
+
"<DENSE_REGION_CAPTION>": "Locate the objects in the image, with their descriptions.",
|
| 75 |
+
"<REGION_PROPOSAL>": "Locate the region proposals in the image."
|
| 76 |
+
},
|
| 77 |
+
"task_prompts_with_input": {
|
| 78 |
+
"<CAPTION_TO_PHRASE_GROUNDING>": "Locate the phrases in the caption: {input}",
|
| 79 |
+
"<REFERRING_EXPRESSION_SEGMENTATION>": "Locate {input} in the image with mask",
|
| 80 |
+
"<REGION_TO_SEGMENTATION>": "What is the polygon mask of region {input}",
|
| 81 |
+
"<OPEN_VOCABULARY_DETECTION>": "Locate {input} in the image.",
|
| 82 |
+
"<REGION_TO_CATEGORY>": "What is the region {input}?",
|
| 83 |
+
"<REGION_TO_DESCRIPTION>": "What does the region {input} describe?",
|
| 84 |
+
"<REGION_TO_OCR>": "What text is in the region {input}?",
|
| 85 |
}
|
| 86 |
}
|