| from huggingface_hub import HfApi | |
| import os | |
| from tqdm import tqdm | |
| TOKEN = os.environ.get("HF_TOKEN", "") | |
| api = HfApi(token=TOKEN) | |
| source = r"D:\desktop\paper\abs\rl_data\ocr_vqa_clean_dataset\train" | |
| repo_id = "zzhowe1207/tet-rl" | |
| api.create_repo(repo_id=repo_id, repo_type="dataset", exist_ok=True) | |
| # 收集 arrow 文件 | |
| all_files = [] | |
| for root, dirs, files in os.walk(source): | |
| for file in files: | |
| if file.endswith('.arrow'): | |
| fpath = os.path.join(root, file) | |
| arcname = os.path.join("ocr_vqa_clean_dataset", "train", os.path.relpath(fpath, source)).replace("\\", "/") | |
| all_files.append((fpath, arcname)) | |
| print(f"共 {len(all_files)} 个 arrow 文件") | |
| # 逐个上传 | |
| for fpath, arcname in tqdm(all_files, desc="上传", unit="file"): | |
| api.upload_file( | |
| path_or_fileobj=fpath, | |
| path_in_repo=arcname, | |
| repo_id=repo_id, | |
| repo_type="dataset" | |
| ) | |
| print(f"搞定!访问: https://huggingface.co/datasets/{repo_id}") |