Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/asakusarinne/huggingfacehub
A library to download models & files from HuggingFace with C#.
https://github.com/asakusarinne/huggingfacehub
Last synced: 8 days ago
JSON representation
A library to download models & files from HuggingFace with C#.
- Host: GitHub
- URL: https://github.com/asakusarinne/huggingfacehub
- Owner: AsakusaRinne
- License: apache-2.0
- Created: 2024-04-18T15:09:53.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-05-30T17:43:30.000Z (5 months ago)
- Last Synced: 2024-10-08T03:41:09.636Z (29 days ago)
- Language: C#
- Size: 79.1 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![HuggingfaceHub Badge](https://img.shields.io/nuget/v/HuggingfaceHub?label=HuggingfaceHub)](https://www.nuget.org/packages/HuggingfaceHub)
**A library to download models & files from HuggingFace with C#.**
## Key features
- [x] Download single file.
- [x] Get information of file and repo.
- [x] Download snapshot (repo).
- [x] Resume download.
- [x] Parallel download multiple files (only in .NET 6 or higher).
- [ ] Upload files.
- [ ] Support repo types other than model.## Installation
```cs
PM> Install-Package HuggingfaceHub
```or
```cs
dotnet add package HuggingfaceHub
```or search `HuggingfaceHub` in the nuget manager tool of Visual Studio.
## Usage
### Download single file
```cs
using Huggingface;
var path = await HFDownloader.DownloadFileAsync("", "");
```### Download repo
```cs
using Huggingface;
var res = await HFDownloader.DownloadSnapshotAsync("");
```### Get repo information
*Currently, only model-type repo is supported.*
```cs
using Huggingface;
var info = await HFDownloader.GetModelInfoAsync("");
```### Download the repo with progress handler
```cs
using Huggingface;
var res = await HFDownloader.DownloadSnapshotAsync("", 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
```cs
using Huggingface;
HFGlobalConfig.EndPoint = "";
```**Please check the definition of `HFGlobalConfig` to see all the configuration you could set.**
## Acknowledgement
This library is mainly adopts from [huggingface_hub](https://github.com/huggingface/huggingface_hub), which is the official implementation written in Python.