Deploy Hugging Face Models

JFrog Artifactory Documentation

ft:sourceType
Paligo

Warning

For Artifactory versions earlier than 7.75.3, It is only possible to deploy lighter models to Hugging Face local repositories due to limitations in the implementation of the Hugging Face client.

This topic describes how to deploy Hugging Face models to an Artifactory repository.

To deploy models to Artifactory using the huggingface_hub library insert your folder name, model name, and revision number into the following command and run it:

Note

Make sure to replace the placeholders in bold with your own model source folder name, model name, and unique identifier.

Warning

Deploying a model using the same UUID as a cached model will cause the new model to override and replace the previous one.

from huggingface_hub import HfApi
api = HfApi()
api.upload_folder(
    folder_path="<MODEL_SOURCE_FOLDER_NAME>",         # Enter the name of the folder on your local machine where your model resides.
    repo_id="<MODEL_NAME>",     # Enter the name of the model, following the Hugging Face repository naming structure 'organization/name'. (models--$<MODEL_NAME>)
revision="<MODEL_UUID>",                 # Enter a unique identifier for your model. We recommend using a git commit revision ID. (snapshots/$<REVISION_NAME>/...files)    
    repo_type="model"
)

For example:

from huggingface_hub import HfApi
api = HfApi()
api.upload_folder(
    folder_path="vit-base-patch16-224",         # Enter the name of the folder on your local machine where your model resides.folder to upload location on the FS
    repo_id="nsi319/legalpegasus",     # Enter the name of the model, following the Hugging Face repository naming structure 'organization/name'. (models--$<MODEL_NAME>)
revision="54ef2872d33bbff28eb09544bdecbf6699f5b0b8",                 # Enter a unique identifier for your model. We recommend using a Git commit revision ID. (snapshots/$<REVISION_NAME>/...files)    
    repo_type="model"
)