Update README.md
Browse files
README.md
CHANGED
@@ -48,4 +48,56 @@ def hugface_upload(yun_folders, repo_id):
|
|
48 |
hugface_upload(yun_folders, repo_id)
|
49 |
|
50 |
```
|
51 |
-
## 本地电脑需要梯子环境,上传可能很慢。可以使用kaggle等中转服务器上传,下载速率400MB/s,上传速率60MB/s。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
hugface_upload(yun_folders, repo_id)
|
49 |
|
50 |
```
|
51 |
+
## 本地电脑需要梯子环境,上传可能很慢。可以使用kaggle等中转服务器上传,下载速率400MB/s,上传速率60MB/s。
|
52 |
+
# 在kaggle上面转存模型:
|
53 |
+
- 第一步:下载文件
|
54 |
+
```notebook
|
55 |
+
!apt install -y aria2
|
56 |
+
!aria2c -x 16 -s 16 -c -k 1M "https://huggingface.co/AstraliteHeart/pony-diffusion-v6/resolve/main/v6.safetensors"
|
57 |
+
```
|
58 |
+
- 第二步:使用上述代码的API上传
|
59 |
+
```python
|
60 |
+
# 功能函数,清理打包上传
|
61 |
+
from pathlib import Path
|
62 |
+
from huggingface_hub import HfApi, login
|
63 |
+
|
64 |
+
repo_id = 'ACCC1380/private-model'
|
65 |
+
yun_folders = ['/kaggle/working'] #kaggle的output路径
|
66 |
+
|
67 |
+
|
68 |
+
def hugface_upload(yun_folders, repo_id):
|
69 |
+
if 5 == 5:
|
70 |
+
hugToken = '********************' #改成你的huggingface_token
|
71 |
+
if hugToken != '':
|
72 |
+
login(token=hugToken)
|
73 |
+
api = HfApi()
|
74 |
+
print("HfApi 类已实例化")
|
75 |
+
print("开始上传文件...")
|
76 |
+
for yun_folder in yun_folders:
|
77 |
+
folder_path = Path(yun_folder)
|
78 |
+
if folder_path.exists() and folder_path.is_dir():
|
79 |
+
for file_in_folder in folder_path.glob('**/*'):
|
80 |
+
if file_in_folder.is_file():
|
81 |
+
try:
|
82 |
+
response = api.upload_file(
|
83 |
+
path_or_fileobj=file_in_folder,
|
84 |
+
path_in_repo=str(file_in_folder.relative_to(folder_path.parent)),
|
85 |
+
repo_id=repo_id,
|
86 |
+
repo_type="dataset"
|
87 |
+
)
|
88 |
+
print("文件上传完成")
|
89 |
+
print(f"响应: {response}")
|
90 |
+
except Exception as e:
|
91 |
+
print(f"文件 {file_in_folder} 上传失败: {e}")
|
92 |
+
continue
|
93 |
+
else:
|
94 |
+
print(f'Error: Folder {yun_folder} does not exist')
|
95 |
+
else:
|
96 |
+
print(f'Error: File {huggingface_token_file} does not exist')
|
97 |
+
|
98 |
+
hugface_upload(yun_folders, repo_id)
|
99 |
+
```
|
100 |
+
- 第三步:等待上传完成:
|
101 |
+
|
102 |
+
|
103 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/64885695cd9f45eeaab57324/Qgz_RzYYRegtZfttIfrre.png)
|