Views
No views yet
huggingface_hub library allows you to interact with the Hugging Face Hub, a platform democratizing open-source Machine Learning for creators and collaborators. Discover pre-trained models and datasets for your projects or play with the thousands of machine learning apps hosted on the Hub. You can also create and share your own models, datasets and demos with the community. The huggingface_hub library provides a simple way to do all these things with Python.huggingface_hub package with pip:pip install huggingface_hubhuggingface_hub comes with optional dependencies useful for some use cases. For example, if you want to use the MCP module, run:pip install "huggingface_hub[mcp]"1from huggingface_hub import hf_hub_download
2
3hf_hub_download(repo_id="tiiuae/falcon-7b-instruct", filename="config.json")1from huggingface_hub import snapshot_download
2
3snapshot_download("stabilityai/stable-diffusion-2-1")1hf auth login
2# or using an environment variable
3hf auth login --token $HUGGINGFACE_TOKEN1from huggingface_hub import create_repo
2
3create_repo(repo_id="super-cool-model")1from huggingface_hub import upload_file
2
3upload_file(
4 path_or_fileobj="/home/lysandre/dummy-test/README.md",
5 path_in_repo="README.md",
6 repo_id="lysandre/test-model",
7)1from huggingface_hub import upload_folder
2
3upload_folder(
4 folder_path="/path/to/local/space",
5 repo_id="username/my-cool-space",
6 repo_type="space",
7)