Deface.NET 10.0.2

dotnet add package Deface.NET --version 10.0.2
                    
NuGet\Install-Package Deface.NET -Version 10.0.2
                    
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="Deface.NET" Version="10.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Deface.NET" Version="10.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Deface.NET" />
                    
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 Deface.NET --version 10.0.2
                    
#r "nuget: Deface.NET, 10.0.2"
                    
#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 Deface.NET@10.0.2
                    
#: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=Deface.NET&version=10.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Deface.NET&version=10.0.2
                    
Install as a Cake Tool

Deface.NET: Video and photo anonymization library for .NET

NuGet

Deface.NET is an MIT licensed library for photo and video processing to achieve anonymized resources. It is based on Ultraface ONNX model for face detection, custom trained YOLO-NAS-S ONNX model for license plate detection and SkiaSharp + FFMpeg image processing.

Installation

Deface.NET is available via NuGet package:

nuget install Deface.NET

Also, you need to install FFMpeg and FFProbe manually.

Using Deface.NET

Deface.NET can be easily added via Dependency Injection:

services.AddDeface(settings =>
{
    ...
});

and then IDefaceService can be easily injected:

public class SomeDIClass
{
    private readonly IDefaceService _defaceService;

    public SomeDIClass(IDefaceService defaceService)
    {
        _defaceService = defaceService;
    }
}
With Standalone Provider

Another way of using Deface.NET is to use DefaceProvider:

IDefaceService defaceService = DefaceProvider.GetDefaceService(options =>
{
    ...
});

var result = defaceService.ProcessImage("1.png", "1-processed.png");

GPU Compatibility

Usage

services.AddDeface(settings =>
{
    ...
    settings.Hardware = Hardware.Cuda(gpuId); // for most configurations gpuId = 0 or gpuId = 1 works
    ...
});

Configuration options

To find out more informatiom, read the XML comments for a given option property/value.

Option Value Required Additional info
FFMpegPath string for videos -
FFProbePath string for images
LoggingLevel None, Basic, Detailed -
AnonimizationShape Ellipse, Rectangle -
AnonimizationMethod GaussianBlur, Mosaic, Color(r, g, b) -
FaceThreshold float 0 <= FaceThreshold <= 1
LicensePlateThreshold float 0 <= LicensePlateThreshold <= 1
DisableFaceDetection bool
DisableLicensePlateDetection bool
RunDetectionEachNFrames int 1 <= RunDetectionEachNFrames
MaskScale float 1 <= MaskScale
ImageFormat Png, Jpeg(quality) -
Hardware Cpu(), Cuda(gpuDeviceId) -
EncodingCodec VP9, H264 -
HideCommercialFeaturesInfo bool -
CustomBaseDirectory string See FAQ's CustomBaseDirectory section.

Commercial Features

Deface.NET's default settings run the library in open-source mode. However, the library includes some features that are licensed differently. Ensure you have the proper license before using them. Deface.NET's creators take no responsibility for the use of commercial features without the necessary rights.

Each enabled commercial feature displays information about its usage, including additional links to the license, etc. You can hide this information by setting HideCommercialFeaturesInfo = false in the settings.

The current list of commercial features requiring an additional license:

Feature Description How to enable
H.264 codec Videos are now being saved as .mp4 with H.264 codec. EncodingCodec = EncodingCodec.H264

FAQ & Known Issues

1. Long paths on Windows

Videos may not be processed correctly on Windows if the destination path exceeds 260 characters. See Microsoft Docs to learn how to enable long paths.

2. GPU Performance

Currently, the Ultraface model used in Deface.NET achieves only ~30% performance improvement when running on a GPU. We are working on optimizing it. NOTE: GPU is strongly recommended with license plate blurring - current model is poorly optimized for CPU usage.

3. CustomBaseDirectory

In some cases (such as with Azure Functions), Deface.NET may throw a FileNotFoundException indicating that Settings.CustomBaseDirectory should be overridden. This happens because the native static method AppContext.BaseDirectory from the System namespace may not return the actual directory containing the application DLLs.

To resolve this, set the CustomBaseDirectory property when registering Deface.NET. In such cases, applications often provide the correct application directory as an environment variable.

4. Missing ONNX Files

In case your application throws an exception about missing .onnx files (most like due to Docker container), to your .csproj file add:

<Target Name="CopyResourcesToPublish" AfterTargets="Publish">
    <ItemGroup>
        <GeneratedResources Include="$(OutputPath)Resources\**" />
    </ItemGroup>

    <Copy SourceFiles="@(GeneratedResources)" DestinationFolder="$(PublishDir)Resources\%(RecursiveDir)" />
</Target>
5. Docker Support

nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 image is tested inside production environment and works correctly.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.2 96 5/20/2026
10.0.1 91 5/20/2026
10.0.0 110 3/25/2026
8.2.0 480 12/10/2025
8.1.0 220 12/3/2025
8.1.0-rc1 584 12/1/2025
8.0.0 266 3/30/2025
8.0.0-rc2 295 3/12/2025
8.0.0-rc1 178 2/28/2025