marlenezw's picture
Upload the python files with Huggingface upload and download functions
df058ca
raw
history blame
1.01 kB
from huggingface_hub import hf_hub_download
from huggingface_hub import login
from huggingface_hub import HfApi
from huggingface_hub import snapshot_download
#not that when passing a file path with "-" in the name add double slashes so it's accpeted by Python
def upload_file(token, local_path, repo_path, repo_id, repo_type):
#Whenever you want to upload files to the Hub, you need to log in to your Hugging Face account
login(token=token)
api = HfApi()
api.upload_file(
path_or_fileobj=local_path,
path_in_repo=repo_path,
repo_id=repo_id,
repo_type=repo_type,
)
def upload_folder(token, local_path, repo_path, repo_id, repo_type,ignore_patterns):
#Whenever you want to upload files to the Hub, you need to log in to your Hugging Face account
login(token=token)
api = HfApi()
api.upload_folder(
folder_path=local_path,
path_in_repo=repo_path,
repo_id=repo_id,
repo_type=repo_type,
ignore_patterns=ignore_patterns,
)