Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update readme #27

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="left">
<a href="README_EN.md">English</a> | 中文
<a href="https://github.com/OpenCSGs/csghub-sdk/blob/main/README_EN.md">English</a> | 中文
SeanHH86 marked this conversation as resolved.
Show resolved Hide resolved
</p>

# CSGHub SDK
Expand Down Expand Up @@ -150,6 +150,35 @@ cookies = None
http_get(url=url, token=token, local_dir=local_dir, file_name=file_name, headers=headers, cookies=cookies)
```

### 单文件上传

```python
from pycsghub.file_upload import http_upload_file

token = "3b77c98077b415ca381ded189b86d5df226e3776"

endpoint = "https://hub.opencsg.com"
repo_type = "model"
repo_id = 'wanghh2000/myprivate1'
result = http_upload_file(repo_id, endpoint=endpoint, token=token, repo_type='model', file_path='test1.txt')
```

### 多文件上传

```python
from pycsghub.file_upload import http_upload_file

token = "3b77c98077b415ca381ded189b86d5df226e3776"

endpoint = "https://hub.opencsg.com"
repo_type = "model"
repo_id = 'wanghh2000/myprivate1'

repo_files = ["1.txt", "2.txt"]
for item in repo_files:
http_upload_file(repo_id=repo_id, repo_type=repo_type, file_path=item, endpoint=endpoint, token=token)
```

### 兼容huggingface的模型加载

huggingface的transformers库支持直接输入huggingface上的repo_id以下载并读取相关模型,如下列所示:
Expand Down
31 changes: 30 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="left">
<a href="README_EN.md">English</a> | 中文
English | <a href="https://github.com/OpenCSGs/csghub-sdk">中文</a>
</p>

# CSGHub SDK
Expand Down Expand Up @@ -149,6 +149,35 @@ cache_dir = '/home/test/'
result = file_download(repo_id, file_name='README.md', cache_dir=cache_dir, endpoint=endpoint, token=token)
```

### Upload file

```python
from pycsghub.file_upload import http_upload_file

token = "3b77c98077b415ca381ded189b86d5df226e3776"

endpoint = "https://hub.opencsg.com"
repo_type = "model"
repo_id = 'wanghh2000/myprivate1'
result = http_upload_file(repo_id, endpoint=endpoint, token=token, repo_type='model', file_path='test1.txt')
SeanHH86 marked this conversation as resolved.
Show resolved Hide resolved
```

### Upload multi-files

```python
from pycsghub.file_upload import http_upload_file

token = "3b77c98077b415ca381ded189b86d5df226e3776"

endpoint = "https://hub.opencsg.com"
repo_type = "model"
repo_id = 'wanghh2000/myprivate1'

repo_files = ["1.txt", "2.txt"]
for item in repo_files:
http_upload_file(repo_id=repo_id, repo_type=repo_type, file_path=item, endpoint=endpoint, token=token)
```

### Model loading compatible with huggingface

The transformers library supports directly inputting the repo_id from Hugging Face to download and load related models, as shown below:
Expand Down