Skip to main content

A simple huggingface client for Python.

Project description

shiertier_huggingface

English | 中文

Introduction

shiertier_huggingface is a Python library designed to simplify interactions with the Hugging Face Hub. It provides a set of utility functions to download models, upload datasets, and manage Hugging Face repositories. This library is particularly useful for managing machine learning models and datasets on the Hugging Face platform.

Installation

You can install shiertier_huggingface via pip:

pip install shiertier_huggingface

Please note that this project is still under development.

Environment Variables and Direct Usage of easy_huggingface_client

Environment Variables

  • HUGGINGFACE_TOKEN: The token used for authentication with the Hugging Face Hub. If not provided during initialization, the client will attempt to retrieve it from this environment variable.

Direct Usage of easy_huggingface_client

You can directly use the easy_huggingface_client object without manually initializing the HuggingfaceClient. This object will automatically retrieve the token from the environment variable.

from shiertier_huggingface import easy_huggingface_client

# Download a model
easy_huggingface_client.download_model(url_or_repo='https://huggingface.co/bert-base-uncased', repo_type='repo', local_dir='./huggingface_models')

# Upload a dataset
easy_huggingface_client.upload_dataset(local_dir='path/to/local_dataset', repo_name='my_dataset_repo', tmp_dir='/root/.tmp')

Usage

Initialization

To use the HuggingfaceClient, you need to initialize it with your Hugging Face token. If the token is not provided during initialization, it will attempt to retrieve it from the HUGGINGFACE_TOKEN environment variable.

from shiertier_huggingface import HuggingfaceClient

# Initialize with a token
client = HuggingfaceClient(token='your_huggingface_token')

Downloading a Model

You can download a model from the Hugging Face Hub using the download_model method. This method allows you to specify the URL or repository name, the repository type, and the local directory where the model will be saved.

# Download a model
client.download_model(url_or_repo='https://huggingface.co/bert-base-uncased', repo_type='repo', local_dir='./huggingface_models')

Uploading a Dataset

You can upload a dataset to the Hugging Face Hub using the upload_dataset method. This method allows you to specify the local directory containing the dataset, the repository name, and an optional temporary directory.

# Upload a dataset
client.upload_dataset(local_dir='path/to/local_dataset', repo_name='my_dataset_repo', tmp_dir='/root/.tmp')

Dependencies

  • huggingface_hub
  • shiertier_i18n
  • shiertier_tar

License

This project is released under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shiertier_huggingface-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shiertier_huggingface-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file shiertier_huggingface-0.1.0.tar.gz.

File metadata

  • Download URL: shiertier_huggingface-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for shiertier_huggingface-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3a91a710da8e1a0f6a0f72df6fb9bade844308d64a970398e32903d7df29afbd
MD5 63dd335b8e6601e7df07fa19c86b3321
BLAKE2b-256 28ad7815b5e665d69d5ed11d7c3a24cd01fcabaf0f6df0a2a15df5f56a6171ea

See more details on using hashes here.

File details

Details for the file shiertier_huggingface-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for shiertier_huggingface-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 434baf79c5bfe30f41af87b7a4cf2baeaf3db56729d28e89a6f1fc144dddc33b
MD5 dc725b5e156a8ea70782bbb9b69ae845
BLAKE2b-256 0be6ca7109fe46f517c1645025b8bd4da2ef035fc6e549c73c4f2f178f303e83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page