HuggingfaceHub
v0.1.2
一个使用 C# 从 HuggingFace 下载模型和文件的库。
下载单个文件。
获取文件和存储库的信息。
下载快照(存储库)。
继续下载。
并行下载多个文件(仅在 .NET 6 或更高版本中)。
上传文件。
支持模型以外的存储库类型。
PM> 安装包 HuggingfaceHub
或者
dotnet 添加包 <your_project> HuggingfaceHub
或者在Visual Studio的nuget管理器工具中搜索HuggingfaceHub
。
using Huggingface;var path = wait HFDownloader.DownloadFileAsync("<RepoId>", "<Filename>");
使用 Huggingface;var res = wait HFDownloader.DownloadSnapshotAsync("<RepoId>");
目前仅支持模型类型的存储库。
使用 Huggingface;var info = wait HFDownloader.GetModelInfoAsync("<RepoId>");
using Huggingface;var res = wait HFDownloader.DownloadSnapshotAsync("<RepoId>",progress: new MyConsoleProgress());class MyConsoleProgress: IGroupedProgress{public void Report(string filename, intprogress){// 在这里完成您的工作。 // `progress` 的范围是 [0, 100]。}}
使用 Huggingface;HFGlobalConfig.EndPoint = "<端点 Url>";
请检查HFGlobalConfig
的定义以查看您可以设置的所有配置。
该库主要采用huggingface_hub,这是用Python编写的官方实现。