Onnxify.HuggingFace
0.3.9
dotnet add package Onnxify.HuggingFace --version 0.3.9
NuGet\Install-Package Onnxify.HuggingFace -Version 0.3.9
<PackageReference Include="Onnxify.HuggingFace" Version="0.3.9" />
<PackageVersion Include="Onnxify.HuggingFace" Version="0.3.9" />
<PackageReference Include="Onnxify.HuggingFace" />
paket add Onnxify.HuggingFace --version 0.3.9
#r "nuget: Onnxify.HuggingFace, 0.3.9"
#:package Onnxify.HuggingFace@0.3.9
#addin nuget:?package=Onnxify.HuggingFace&version=0.3.9
#tool nuget:?package=Onnxify.HuggingFace&version=0.3.9
Warning This package is currently in active development and research. Its public API is unstable and may change radically in future versions.
Onnxify.HuggingFace
Onnxify.HuggingFace downloads model repository contents from Hugging Face into a local directory. It is intended for ONNX model workflows where you want to fetch only the files needed for a specific runtime variant, such as bf16, instead of cloning or downloading the entire repository.
Install
dotnet add package Onnxify.HuggingFace
What It Provides
- Download all files listed by a Hugging Face model repository.
- Preserve repository-relative paths in the target directory.
- Restrict downloads with include and exclude path filters.
- Track download progress through a callback or
IProgress<HuggingFaceDownloadProgress>. - Use a revision and optional Hugging Face access token.
- Avoid writing files outside the target directory when repository paths are malformed.
Basic Usage
using Onnxify.HuggingFace;
var client = new HuggingFaceClient();
var result = await client.DownloadRepositoryAsync(
repositoryId: "onnx-community/gemma-4-E2B-it-ONNX",
targetDirectoryPath: "models/gemma-fp16",
options: new HuggingFaceDownloadOptions
{
Revision = "main",
IncludePath = path =>
path.Contains("fp16", StringComparison.OrdinalIgnoreCase)
|| path.EndsWith(".json", StringComparison.OrdinalIgnoreCase)
|| path.EndsWith(".model", StringComparison.OrdinalIgnoreCase),
ExcludePath = path => path.EndsWith(".md5", StringComparison.OrdinalIgnoreCase),
ProgressCallback = progress =>
{
if (progress.Completed)
{
Console.WriteLine($"Downloaded {progress.FileIndex}/{progress.FileCount}: {progress.RepositoryPath}");
}
},
Overwrite = true,
}
);
Console.WriteLine($"Downloaded files: {result.DownloadedFileCount}");
Authentication
For private or gated repositories, pass an access token:
var result = await client.DownloadRepositoryAsync(
"owner/private-model",
"models/private-model",
new HuggingFaceDownloadOptions
{
AccessToken = Environment.GetEnvironmentVariable("HF_TOKEN"),
}
);
CLI
The Onnxify.CLI package also exposes this workflow:
onnxify hf download onnx-community/gemma-4-E2B-it-ONNX models/gemma-bf16 --variant bf16 --exclude "*.md5" --overwrite
Repository
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
## 0.3.9
- Aligned the package version with the 0.3.9 Onnxify package family release.
## 0.3.6
- Aligned the package version with the 0.3.6 Onnxify package family release.
## 0.3.5
- Aligned the package version with the 0.3.5 Onnxify package family release.
## 0.3.3
- Aligned the package version with the 0.3.3 Onnxify package family release.
## 0.3.2
- Aligned the package version with the 0.3.2 Onnxify package family release.
## 0.3.0
- Aligned the package version with the 0.3.0 Onnxify package family release.
## 0.2.0
- Aligned the package version with the 0.2.0 Onnxify package family release.
## 0.1.3
- Initial release.
- Added `HuggingFaceClient` for downloading Hugging Face model repository files into a local directory.
- Added include and exclude path filters for downloading only selected variants, such as `bf16`.
- Added progress reporting through `ProgressCallback` and `IProgress<HuggingFaceDownloadProgress>`.
- Added revision, access token, overwrite, and path-safety support.