SoundOfWater / upload_to_hub.py
bpiyush's picture
Upload upload_to_hub.py with huggingface_hub
41ce9e0 verified
raw
history blame
868 Bytes
"""Uploads files/folders to HF hub for use with Spaces."""
import os
from huggingface_hub import Repository, HfApi
api = HfApi()
repo_id = "bpiyush/SoundOfWater"
repo_type = "space"
upload_file = "upload_to_hub.py"
if upload_file is not None:
print("Uploading file: ", upload_file)
assert isinstance(upload_file, str), "Please provide a valid file path."
api.upload_file(
path_or_fileobj=f"./{upload_file}",
path_in_repo=upload_file,
repo_id=repo_id,
repo_type=repo_type,
)
upload_folder = None
if upload_folder is not None:
print("Uploading folder: ", upload_folder)
assert isinstance(upload_folder, str), "Please provide a valid folder path."
api.upload_folder(
folder_path=f"./{upload_folder}",
path_in_repo=upload_folder,
repo_id=repo_id,
repo_type=repo_type,
)