Florence-2 Large

FLORENCE_2_LARGE

Microsoft's Florence-2 Large looks at an image and captions it, reads its text, boxes the objects in it, or finds the things a phrase names.

Vision & Analysisvisioncaptioningocrobject-detectiongroundingmitFine-tunable
Florence-2 Large: Vision & Analysis model on Kainguru

About Florence-2 Large

Good to know

  • Images are PNG, JPEG or WebP, at most 20 MB, 8192 pixels a side and 40 megapixels.
  • Fine-tuning data is a JSONL manifest plus the images it names: 4 to 5000 examples in at most 1000 files and 4 GB in all, each manifest and image at most 20 MB.
  • Region targets are {"bboxes": [[x1, y1, x2, y2], ...], "labels": [...]}, or for ocr_with_region {"quad_boxes": [[x1, y1, x2, y2, x3, y3, x4, y4], ...], "labels": [...]}, in pixels; a phrase_grounding example also needs "text", the phrases its labels come from.
  • Each example has at most 100 regions; labels and phrase_grounding text are at most 256 characters and contain no "<"; text targets are at most 4000 characters; every target is at most 1024 tokens once encoded, and a longer one is refused rather than cut.
  • Labels for object_detection, dense_region_caption and phrase_grounding must be ASCII, because Florence-2 drops other characters from them; ocr and ocr_with_region keep any script.

Florence-2 Large inputs and output

NameTypeRequiredDefaultDetails
imagefileYes—The image to analyse: PNG, JPEG or WebP, at most 20 MB, 8192 pixels a side and 40 megapixels.
image/png, jpeg, webp
max_new_tokensintegerNo1024Upper bound on the length of the generated answer.
1–1024
tasktextNocaptioncaption, detailed_caption or more_detailed_caption describe the image; ocr reads its text and ocr_with_region also boxes each line; object_detection and dense_region_caption box the objects; phrase_grounding boxes the things named in text.
Allowed: caption, detailed_caption, more_detailed_caption, ocr, ocr_with_region, object_detection, dense_region_caption, phrase_grounding
texttextWhen task = phrase_grounding—Only for phrase_grounding: a caption or phrases naming what to find in the image, without "<".
Max 256 characters

Output. JSON: {"task": ..., "result": ..., "image_size": [width, height]}; result is text for the caption and ocr tasks, {"bboxes": [[x1, y1, x2, y2], ...], "labels": [...]} for the region tasks and {"quad_boxes": [...], "labels": [...]} for ocr_with_region.

Run Florence-2 Large with the API

Send your API key in the X-API-Key header. The run is asynchronous: submit it, then poll it until it finishes. Create an API key.

cURL
curl -X POST "https://api.kainguru.com/api/v1/executions?mlFlowId=FLORENCE_2_LARGE" \
  -H "X-API-Key: kg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "image": "https://example.com/input.png",
    "max_new_tokens": 1024,
    "task": "caption"
  },
  "outputFormat": "json"
}'

# Poll until the execution reaches a terminal state
curl "https://api.kainguru.com/api/v1/executions/{executionId}" \
  -H "X-API-Key: kg_your_api_key"
Python
from kainguru import KainguruClient

with KainguruClient(api_key="kg_your_api_key", base_url="https://api.kainguru.com/api") as client:
    submitted = client.executions.execute(
        "FLORENCE_2_LARGE",
        {
          "image": "https://example.com/input.png",
          "max_new_tokens": 1024,
          "task": "caption"
        },
        output_format="json",
    )
    result = client.executions.await_completion(submitted.id)
    print(result.execution.output)

Fine-tune Florence-2 Large

You can fine-tune Florence-2 Large on your own data and run the tuned model through the same API. Dataset: A JSONL manifest plus the images it names, one {"file", "task", "target"} per line; target is text, or {"bboxes" or "quad_boxes": [...], "labels": [...]} in pixels. 4 to 5000 examples, 4 GB in all, 20 MB a file. More limits: Good to know, in the README.

The steps are in the docs.

Florence-2 Large pricing

Price per request: 0.0437 credits ($0.000437). The price is shown again before every run; all prices are on the pricing page.

Licence and source

GLM-OCR: Vision & Analysis model on Kainguru
Vision & Analysis

GLM-OCR

GLM-OCR reads documents in pictures: it writes out the text of a page, tables as HTML and formulas as LaTeX, and can…

Fine-tunable
Moondream 2: Vision & Analysis model on Kainguru
Vision & Analysis

Moondream 2

Moondream 2 is a small vision model: it answers questions about a picture, writes short, normal or long captions and…

Fine-tunable
Table Transformer: Vision & Analysis model on Kainguru
Vision & Analysis

Table Transformer

Reads the structure of a table in an image, finding its rows, columns, column headers, projected row headers and…

Fine-tunable
BLIP2 Flan T5 XL: Vision & Analysis model on Kainguru
Vision & Analysis

BLIP2 Flan T5 XL

Describes a photo in a sentence or answers a question about it in plain English.

Fine-tunable
Docling Layout Heron: Vision & Analysis model on Kainguru
Vision & Analysis

Docling Layout Heron

Finds the layout of a document page, such as text blocks, titles, section headers, tables, pictures, captions…

Fine-tunable
EasyOCR: Vision & Analysis model on Kainguru
Vision & Analysis

EasyOCR

EasyOCR finds the lines of text in a photo or a scan and reads each one, returning every line with its box and its…

Fine-tunable