OnnxModelDownloader
Models & Types · AiDotNet.Onnx
Downloads ONNX models from HuggingFace Hub and other repositories.
Implements: IDisposable, IOnnxModelDownloader
For Beginners
Instead of manually downloading model files, use this class:
How It Works
This class provides functionality to download pre-trained ONNX models from HuggingFace Hub with automatic caching, progress reporting, and resume support.
Constructors
| Constructor | Summary |
|---|---|
OnnxModelDownloader(HttpClient httpClient, string cacheDirectory, bool ownsHttpClient) |
Creates a new OnnxModelDownloader with a custom HttpClient. |
OnnxModelDownloader(string cacheDirectory) |
Creates a new OnnxModelDownloader with default settings. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<string> GetCachedFiles(string modelId) |
Gets the files cached for a specific model. |
IReadOnlyList<string> ListCachedModels() |
Lists all cached models. |
Task<IReadOnlyDictionary<string, string>> DownloadMultipleAsync(string modelId, IEnumerable<string> fileNames, IProgress<double> progress, CancellationToken cancellationToken) |
|
Task<string> DownloadAsync(string modelId, string fileName, IProgress<double> progress, CancellationToken cancellationToken) |
|
Task<string> DownloadFromUrlAsync(string url, IProgress<double> progress, CancellationToken cancellationToken) |
Downloads a model from a direct URL (not HuggingFace). |
long GetCacheSize() |
|
string GetCachedPath(string modelId, string fileName) |
|
void ClearCache(string modelId) |
|
void Dispose() |
Disposes the downloader and the HttpClient if owned. |
Fields
| Field | Summary |
|---|---|
string HuggingFaceBaseUrl |
The base URL for HuggingFace Hub. |