Skip to content

A library to download models & files from HuggingFace with C#.

License

Notifications You must be signed in to change notification settings

AsakusaRinne/HuggingfaceHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HuggingfaceHub Badge

A library to download models & files from HuggingFace with C#.

Key features

  • 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.

Installation

PM> Install-Package HuggingfaceHub

or

dotnet add package <your_project> HuggingfaceHub

or search HuggingfaceHub in the nuget manager tool of Visual Studio.

Usage

Download single file

using Huggingface;
var path = await HFDownloader.DownloadFileAsync("<RepoId>", "<Filename>");

Download repo

using Huggingface;
var res = await HFDownloader.DownloadSnapshotAsync("<RepoId>");

Get repo information

Currently, only model-type repo is supported.

using Huggingface;
var info = await HFDownloader.GetModelInfoAsync("<RepoId>");

Download the repo with progress handler

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].
    }
}

Customize the endpoint

using Huggingface;
HFGlobalConfig.EndPoint = "<Endpoint Url>";

Please check the definition of HFGlobalConfig to see all the configuration you could set.

Acknowledgement

This library is mainly adopts from huggingface_hub, which is the official implementation written in Python.

About

A library to download models & files from HuggingFace with C#.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages