A library to download models & files from HuggingFace with C#.
- Download single file.
- Get information of file and repo.
- Download snapshot (repo).
- Resume download.
- Parallel download multiple files (only in .NET 6 or higher).
- Upload files.
- Support repo types other than model.
PM> Install-Package HuggingfaceHub
or
dotnet add package <your_project> HuggingfaceHub
or search HuggingfaceHub
in the nuget manager tool of Visual Studio.
using Huggingface;
var path = await HFDownloader.DownloadFileAsync("<RepoId>", "<Filename>");
using Huggingface;
var res = await HFDownloader.DownloadSnapshotAsync("<RepoId>");
Currently, only model-type repo is supported.
using Huggingface;
var info = await HFDownloader.GetModelInfoAsync("<RepoId>");
using Huggingface;
var res = await HFDownloader.DownloadSnapshotAsync("<RepoId>", progress: new MyConsoleProgress());
class MyConsoleProgress: IGroupedProgress
{
public void Report(string filename, int progress)
{
// Do your work here.
// `progress` is in range [0, 100].
}
}
using Huggingface;
HFGlobalConfig.EndPoint = "<Endpoint Url>";
Please check the definition of HFGlobalConfig
to see all the configuration you could set.
This library is mainly adopts from huggingface_hub, which is the official implementation written in Python.