VOOZH about

URL: https://www.nuget.org/packages/Florence2/

⇱ NuGet Gallery | Florence2 25.12.63049




👁 Image
Florence2 25.12.63049

dotnet add package Florence2 --version 25.12.63049
 
 
NuGet\Install-Package Florence2 -Version 25.12.63049
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Florence2" Version="25.12.63049" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Florence2" Version="25.12.63049" />
 
Directory.Packages.props
<PackageReference Include="Florence2" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Florence2 --version 25.12.63049
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Florence2, 25.12.63049"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Florence2@25.12.63049
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Florence2&version=25.12.63049
 
Install as a Cake Addin
#tool nuget:?package=Florence2&version=25.12.63049
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Florence2 — C# Wrapper for Microsoft’s Florence-2 Vision Model

A lightweight, easy-to-use C# library that provides access to Microsoft’s Florence-2-base models for advanced image understanding tasks — including captioning, OCR, object detection, and phrase grounding.

This project gives .NET developers a clean API to run Florence-2 locally without needing Python or the original reference implementation.

📦 NuGet: https://www.nuget.org/packages/Florence2


✨ Features

  • Image Captioning Generate concise or richly detailed descriptions of images.

  • Optical Character Recognition (OCR) Extract text from entire images or specific regions.

  • Region-based OCR Provide bounding boxes and retrieve text only from selected areas.

  • Object Detection Detect and label objects with bounding boxes.

  • Phrase Grounding (optional) Highlight image regions relevant to a given phrase or textual query.

  • Local Model Execution Automatically downloads and loads the Florence-2-base ONNX models.


🚀 Quick Start

1. Install the package

dotnet add package Florence2

Or get it on NuGet: https://www.nuget.org/packages/Florence2


2. Example Usage

using Florence2;

// Download models if needed
var modelSource = new FlorenceModelDownloader("./models");
await modelSource.DownloadModelsAsync();

// Create model instance
var model = new Florence2Model(modelSource);

// Load an image stream
using var imgStream = File.OpenRead("car.jpg");

// Optional text for phrase grounding (may be null)
string phrase = "the red car";

// Choose a task: Captioning / OCR / ObjectDetection / PhraseGrounding / RegionOCR
var task = TaskTypes.OCR_WITH_REGION;

// Run inference
var results = model.Run(task, imgStream, textInput: phrase);

// View results
Console.WriteLine(JsonSerializer.Serialize(results, new JsonSerializerOptions() { WriteIndented = true }));

📚 Supported Tasks

Task Description
TaskTypes.OCR Optical Character Recognition: Extracts all text recognized in the image.
TaskTypes.OCR_WITH_REGION Extracts all text from the image and provides the bounding box (quad-box) for each detected text region.
TaskTypes.CAPTION Generates a brief caption describing the entire image.
TaskTypes.DETAILED_CAPTION Generates a detailed description of the image, covering more elements than the standard caption.
TaskTypes.MORE_DETAILED_CAPTION Generates a highly comprehensive and lengthy description of the image contents.
TaskTypes.OD Object Detection: Detects objects in the image and provides their bounding boxes and class labels.
TaskTypes.DENSE_REGION_CAPTION Detects a large number of regions (densely packed) and provides a caption/label for each bounding box.
TaskTypes.CAPTION_TO_PHRASE_GROUNDING Phrase Grounding: Highlights/localizes regions (bounding boxes) that correspond to specific phrases provided in a text input.
TaskTypes.REGION_TO_SEGMENTATION Generates a segmentation mask for an object defined by a provided bounding box.
TaskTypes.OPEN_VOCABULARY_DETECTION Detects objects matching a provided text prompt (similar to phrase grounding, but often used to detect specific classes).
TaskTypes.REGION_TO_CATEGORY Classifies the object contained within a specific provided bounding box.
TaskTypes.REGION_TO_DESCRIPTION Generates a description or caption for a specific region defined by a provided bounding box.
TaskTypes.REGION_TO_OCR Extracts text specifically from a region defined by a provided bounding box.
TaskTypes.REGION_PROPOSAL Identifies and outputs bounding boxes for salient regions or potential objects in the image without labels.

📦 Model Files

Models are downloaded automatically via FlorenceModelDownloader, but you can also supply your own model directory. The library expects Florence-2-base ONNX models compatible with Microsoft’s open-source release.


🤝 Contributing

Contributions, issues, and pull requests are welcome! If you find a bug or have a feature request, feel free to open an issue.


📄 License

MIT — see the LICENSE file for details.

Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Florence2:

Package Downloads
Mostlylucid.LucidRAG.ImageSummarizer

Core image analysis pipeline with OCR, motion detection, and vision model captioning

Mostlylucid.OcrNer

Local-first OCR, Named Entity Recognition, and Vision captioning library. Uses Tesseract OCR, BERT NER (ONNX), Florence-2 vision, and ImageSharp preprocessing. Auto-downloads all models on first use - zero manual setup required.

mostlylucid.llmalttext

AI-powered alt text generation and OCR using Florence-2 Vision Language Model. Automatically generates descriptive alt text for images and extracts text content.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
25.12.63049 5,357 12/7/2025
25.12.63048 252 12/7/2025
25.12.63047 261 12/7/2025
25.7.59767 2,258 7/18/2025
24.11.53800 4,943 11/18/2024
24.11.53799 197 11/18/2024
24.10.53218 776 10/25/2024
24.9.51644 1,279 9/3/2024
24.7.50588 768 7/25/2024
24.7.50576 181 7/25/2024
24.7.50575 173 7/25/2024
24.7.50572 187 7/25/2024
24.7.50455 207 7/23/2024
24.7.50454 217 7/23/2024