from huggingface_hub import HfApi | |
import os | |
# 创建HfApi实例 | |
api = HfApi() | |
# 定义数据集路径和目标URL | |
dataset_dir = "/home/yiyangai/stephenqs/datasets/VIST" | |
repo_url = "StarThomas1002/my-VIST-dataset" | |
# 遍历临时目录中的文件并分批上传 | |
for root, dirs, files in os.walk(dataset_dir): | |
for file_name in files: | |
file_path = os.path.join(root, file_name) | |
relative_path = os.path.relpath(file_path, dataset_dir) | |
# 分块上传文件 | |
api.upload_file( | |
path_or_fileobj=file_path, | |
path_in_repo=relative_path, | |
repo_id=repo_url, | |
repo_type="dataset" | |
) | |