Installation
Florence2-Sharp is distributed on NuGet as Florence2.
dotnet add package Florence2
Or, with the PackageReference syntax in your .csproj:
<ItemGroup>
<PackageReference Include="Florence2" Version="*" />
</ItemGroup>
Target frameworks
| Target | Status |
|---|---|
| .NET 8.0 / 9.0 | First-class. |
| .NET 6.0 / 7.0 | Supported. |
| .NET Framework | Not supported — depends on modern ONNX Runtime. |
What gets installed
Florence2.dll— the managed library.- The CPU ONNX Runtime NuGet package, which ships native binaries for Windows, Linux, and macOS.
- Tokeniser resources embedded in the assembly.
The model files themselves are not included in the package — they are downloaded on first run (see Quick Start).
GPU acceleration (optional)
For CUDA, DirectML, or CoreML acceleration, replace the bundled CPU runtime with the matching ONNX Runtime package:
dotnet add package Microsoft.ML.OnnxRuntime.Gpu # CUDA (Windows, Linux)
dotnet add package Microsoft.ML.OnnxRuntime.DirectML # Windows DirectML
You don't need to change any Florence2-Sharp code — the runtime picks the best available execution provider automatically.
Verify the install
using Florence2;
Console.WriteLine($"Florence2 task count: {Enum.GetValues<TaskTypes>().Length}");
If that compiles and prints 15, the package is ready. Continue with the Quick Start.