# 上传测试资源到 HuggingFace 指南 ## 快速开始 ### 1. 设置 HuggingFace Token ```bash export HF_TOKEN=your_huggingface_token_here ``` 获取 token:https://huggingface.co/settings/tokens ### 2. 运行上传脚本 ```bash # 从项目根目录运行 python scripts/upload_test_resources.py ``` 脚本会: - 自动读取 `HF_TOKEN` 环境变量 - 从 `tests/resources_config.yaml` 读取仓库配置 - 上传 `test_resources_organized/` 目录的所有文件 - 保持目录结构 ### 3. 验证上传 访问:https://huggingface.co/datasets/TsienDragon/qwen-image-finetune-test-resources ## 上传后的操作 ### 删除本地旧资源 ```bash # 删除旧的测试资源目录 rm -rf tests/resources/ # 删除组织化的资源目录(可选,已上传到 HuggingFace) rm -rf test_resources_organized/ ``` ### 测试自动下载 ```bash # 运行测试,资源会自动下载 pytest tests/src/models/test_flux_transform_custom.py -v # 检查下载的资源 ls -lh tests/resources/ ``` ## 添加新资源 ### 1. 添加文件到组织化目录 ```bash # 例如:添加新的训练样本 mkdir -p test_resources_organized/flux_training/face_segmentation/sample3/ cp your_files/* test_resources_organized/flux_training/face_segmentation/sample3/ ``` ### 2. 更新配置 编辑 `tests/resources_config.yaml`,添加新的资源组和测试依赖。 ### 3. 重新上传 ```bash python scripts/upload_test_resources.py ``` HuggingFace 会自动处理增量上传,只上传新增或修改的文件。 ## 目录结构 ``` test_resources_organized/ ├── README.md # 资源说明 ├── UPLOAD_GUIDE.md # 本文件 ├── flux_models/ # 模型测试数据 │ └── transformer/ │ └── input/ ├── flux_training/ # 训练测试数据 │ └── face_segmentation/ │ ├── sample1/ │ └── sample2/ ├── flux_sampling/ # 采样测试数据 │ └── embeddings/ └── reference_outputs/ # 参考输出 └── images/ ``` ## 常见问题 ### Q: 如何使用私有仓库? ```bash python scripts/upload_test_resources.py --private ``` ### Q: 如何上传到不同的仓库? ```bash python scripts/upload_test_resources.py --repo-id your-username/your-repo ``` ### Q: 如何查看上传进度? 脚本会显示上传进度和文件列表。 ### Q: 上传失败怎么办? 1. 检查 token 是否有效 2. 检查网络连接 3. 确认仓库权限 4. 重新运行脚本(会自动续传) ## 相关文档 - 详细文档:`docs/test_resources_management.md` - 配置文件:`tests/resources_config.yaml` - 下载工具:`tests/utils/test_resources.py`