Create README.md (#4)
Browse files- Create README.md (8ef600a167bd238c0df5a9d8b9af4928a19d9a97)
Co-authored-by: ABCD9099 <ACCA225@users.noreply.huggingface.co>
README.md
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 关于
|
2 |
+
## 此huggingface库主要存储本人电脑的一些重要文件
|
3 |
+
## 如果无法下载文件,使用huggingface中国镜像站:hf-mirror.com
|
4 |
+
### 如果你也想要在此处永久备份文件,可以参考我的上传代码:
|
5 |
+
```python
|
6 |
+
# 功能函数,清理打包上传
|
7 |
+
from pathlib import Path
|
8 |
+
from huggingface_hub import HfApi, login
|
9 |
+
|
10 |
+
repo_id = 'ACCC1380/private-model'
|
11 |
+
yun_folders = ['/kaggle/input']
|
12 |
+
|
13 |
+
|
14 |
+
def hugface_upload(yun_folders, repo_id):
|
15 |
+
if 5 == 5:
|
16 |
+
hugToken = '********************' #改成你的huggingface_token
|
17 |
+
if hugToken != '':
|
18 |
+
login(token=hugToken)
|
19 |
+
api = HfApi()
|
20 |
+
print("HfApi 类已实例化")
|
21 |
+
print("开始上传文件...")
|
22 |
+
for yun_folder in yun_folders:
|
23 |
+
folder_path = Path(yun_folder)
|
24 |
+
if folder_path.exists() and folder_path.is_dir():
|
25 |
+
for file_in_folder in folder_path.glob('**/*'):
|
26 |
+
if file_in_folder.is_file():
|
27 |
+
try:
|
28 |
+
response = api.upload_file(
|
29 |
+
path_or_fileobj=file_in_folder,
|
30 |
+
path_in_repo=str(file_in_folder.relative_to(folder_path.parent)),
|
31 |
+
repo_id=repo_id,
|
32 |
+
repo_type="dataset"
|
33 |
+
)
|
34 |
+
print("文件上传完成")
|
35 |
+
print(f"响应: {response}")
|
36 |
+
except Exception as e:
|
37 |
+
print(f"文件 {file_in_folder} 上传失败: {e}")
|
38 |
+
continue
|
39 |
+
else:
|
40 |
+
print(f'Error: Folder {yun_folder} does not exist')
|
41 |
+
else:
|
42 |
+
print(f'Error: File {huggingface_token_file} does not exist')
|
43 |
+
|
44 |
+
hugface_upload(yun_folders, repo_id)
|
45 |
+
|
46 |
+
```
|
47 |
+
## 本地电脑需要梯子环境,上传可能很慢,可以使用kaggle等中转服务器上传,上传速率60MB/s。
|