File size: 2,117 Bytes
36b194b
 
 
 
 
 
 
 
5640e1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36b194b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
license: apache-2.0
language:
- ch
---
# 此huggingface库主要存储本人电脑的一些重要文件
## 如果无法下载文件,把下载链接的huggingface.co改成hf-mirror.com 即可
## 如果你也想要在此处永久备份文件,可以参考我的上传代码:
```python
# 功能函数,清理打包上传
from pathlib import Path
from huggingface_hub import HfApi, login

repo_id = 'ACCC1380/private-model'
yun_folders = ['/kaggle/input']


def hugface_upload(yun_folders, repo_id):
    if 5 == 5:
        hugToken = '********************' #改成你的huggingface_token
        if hugToken != '':
            login(token=hugToken)
            api = HfApi()
            print("HfApi 类已实例化")
            print("开始上传文件...")
            for yun_folder in yun_folders:
                folder_path = Path(yun_folder)
                if folder_path.exists() and folder_path.is_dir():
                    for file_in_folder in folder_path.glob('**/*'):
                        if file_in_folder.is_file():
                            try:
                                response = api.upload_file(
                                    path_or_fileobj=file_in_folder,
                                    path_in_repo=str(file_in_folder.relative_to(folder_path.parent)),
                                    repo_id=repo_id,
                                    repo_type="dataset"
                                )
                                print("文件上传完成")
                                print(f"响应: {response}")
                            except Exception as e:
                                print(f"文件 {file_in_folder} 上传失败: {e}")
                                continue
                else:
                    print(f'Error: Folder {yun_folder} does not exist')
        else:
            print(f'Error: File {huggingface_token_file} does not exist')

hugface_upload(yun_folders, repo_id)

```
## 本地电脑需要梯子环境,上传可能很慢。可以使用kaggle等中转服务器上传,下载速率400MB/s,上传速率60MB/s。