Quickly push your spaCy pipelines to the Hugging Face Hub
Project description
spacy-huggingface-hub: Push your spaCy pipelines to the Hugging Face Hub
This package provides a CLI command for uploading any trained spaCy pipeline packaged with spacy package
to the Hugging Face Hub. It auto-generates all meta information for you, uploads a pretty README (requires spaCy v3.1+) and handles version control under the hood.
🤗 About the Hugging Face Hub
The Hugging Face Hub hosts Git-based repositories which are storage spaces that can contain all your files. These repositories have multiple advantages: versioning (commit history and diffs), branches, useful metadata about their tasks, languages, metrics and more, browser-based visualizers to explore the models interactively in your browser, as well as an API to use the models in production.
🚀 Quickstart
You can install spacy-huggingface-hub
from pip:
pip install spacy-huggingface-hub
To check if the command has been registered successfully:
python -m spacy huggingface-hub --help
Hugging Face uses Git Large File Storage (LFS) to handle files larger than 10mb. You can find instructions on how to download it here.
You can then upload any pipeline packaged with spacy package
. Make sure to set --build wheel
to output a binary .whl
file. The uploader will read all metadata from the pipeline package, including the auto-generated pretty README.md
and the model details available in the meta.json
.
huggingface-cli login
python -m spacy package ./en_ner_fashion ./output --build wheel
cd ./output/en_ner_fashion-0.0.0/dist
python -m spacy huggingface-hub push en_ner_fashion-0.0.0-py3-none-any.whl
The command will output two things:
- Where to find your repo in the Hub! For example, https://huggingface.co/spacy/en_core_web_sm
- And how to install the pipeline directly from the Hub!
pip install https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl
Now you can share your pipelines very quickly with others. Additionally, you can also test your pipeline directly in the browser!
⚙️ Usage and API
If spaCy is already installed in the same environment, this package automatically adds the spacy huggingface-hub
commands to the CLI. If you don't have spaCy installed, you can also execute the CLI directly via the package.
push
python -m spacy huggingface-hub push [whl_path] [--org] [--msg] [--local-repo] [--verbose]
python -m spacy_huggingface_hub push [whl_path] [--org] [--msg] [--local-repo] [--verbose]
Argument | Type | Description |
---|---|---|
whl_path |
str / Path |
The path to the .whl file packaged with spacy package . |
--org , -o |
str | Optional name of organization to which the pipeline should be uploaded. |
--msg , -m |
str | Commit message to use for update. Defaults to "Update spaCy pipeline" . |
--local-repo , -l |
str / Path |
Local path to the model repository (will be created if it doesn't exist). Defaults to hub in the current working directory. |
--verbose , -V |
bool | Output additional info for debugging, e.g. the full generated hub metadata. |
Usage from Python
Instead of using the CLI, you can also call the push
function from Python. It returns a dictionary containing the "url"
of the published model and the "whl_url"
of the wheel file, which you can install with pip install
from spacy_huggingface_hub import push
result = push("./en_ner_fashion-0.0.0-py3-none-any.whl")
print(result["url"])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file spacy-huggingface-hub-0.0.4.tar.gz
.
File metadata
- Download URL: spacy-huggingface-hub-0.0.4.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71eb914d780e3716871c0475fd36023081e848ab87a244104e904184d83ce959 |
|
MD5 | 6b8c32ebae21baeb3c7ba7acf6810e92 |
|
BLAKE2b-256 | 1470e7c35fd6711fedc9e9bfd7272d85d24b71186c2d43f82d153c1b2ff7ee5f |
File details
Details for the file spacy_huggingface_hub-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: spacy_huggingface_hub-0.0.4-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b83fcb7a4fed315868a1f1b7cce7a9a898e06d7ae7fbfda7f3ffcc2dca6a2a1 |
|
MD5 | da2762b1840b2c5ffb0630ce0d83fbe0 |
|
BLAKE2b-256 | 5bd11bd690ff7d6149cde2ebdfcd4031a5df2de4a4a6b14a673447879cb9e11f |