#from huggingface_hub import HfApi, HfFolder, Repository | |
# | |
#dataset_dir = "/home/yiyangai/stephenqs/datasets/wikihow" | |
#repo_name = "my-wikihow-dataset" | |
#repo_url = f"https://huggingface.co/datasets/StarThomas1002/{repo_name}" | |
# | |
# | |
#api = HfApi() | |
#token = HfFolder.get_token() | |
from huggingface_hub import HfApi | |
# 设置变量 | |
dataset_dir = '/home/yiyangai/stephenqs/datasets/wikihow' | |
repo_name = 'my-wikihow-dataset' | |
username = 'StarThomas1002' | |
# 初始化 API | |
api = HfApi() | |
# 上传文件 | |
api.upload_folder( | |
folder_path=dataset_dir, | |
path_in_repo=".", | |
repo_id=f"{username}/{repo_name}", | |
repo_type="dataset" | |
) | |
repo = Repository(local_dir=dataset_dir, clone_from=repo_url) | |
repo.push_to_hub() | |
print(f"数据集已上传到 {repo_url}") | |