Coder Social home page Coder Social logo

huggingfacehub's Introduction

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.

huggingfacehub's People

Contributors

asakusarinne avatar

Stargazers

xbotter avatar Konstantin S. avatar Martin Evans avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.