Add Civitai support and usage examples to README
Added Civitai badge, URL transformation instructions, and Python usage examples for the Civitai AI model platform to both English and Chinese README files. This update documents how to accelerate Civitai model downloads and API access via the Xget service.
This commit is contained in:
1 parent
a9843ab948
commit
44e31aa5bd
2 files changed
+132
No files matched your search
@@ -15,6 +15,7 @@
|
||||
[](#sourceforge)
|
||||
[](#aosp-android-open-source-project)
|
||||
[](#hugging-face-mirror)
|
||||
[](#civitai-ai-model-platform)
|
||||
[](#npm-package-acceleration)
|
||||
[](#python-package-acceleration)
|
||||
[](#conda-package-acceleration)
|
||||
@@ -138,6 +139,7 @@ Using the public instance **`xget.xi-xu.me`** or your own deployed instance, sim
|
||||
| SourceForge | `sf` | `https://sourceforge.net/...` | `https://xget.xi-xu.me/sf/...` |
|
||||
| AOSP | `aosp` | `https://android.googlesource.com/...` | `https://xget.xi-xu.me/aosp/...` |
|
||||
| Hugging Face | `hf` | `https://huggingface.co/...` | `https://xget.xi-xu.me/hf/...` |
|
||||
| Civitai | `civitai` | `https://civitai.com/...` | `https://xget.xi-xu.me/civitai/...` |
|
||||
| npm | `npm` | `https://registry.npmjs.org/...` | `https://xget.xi-xu.me/npm/...` |
|
||||
| PyPI | `pypi` | `https://pypi.org/...` | `https://xget.xi-xu.me/pypi/...` |
|
||||
| conda | `conda` | `https://repo.anaconda.com/...` and `https://conda.anaconda.org/...` | `https://xget.xi-xu.me/conda/...` and `https://xget.xi-xu.me/conda/community/...` |
|
||||
@@ -248,6 +250,28 @@ https://huggingface.co/datasets/rajpurkar/squad/resolve/main/plain_text/train-00
|
||||
https://xget.xi-xu.me/hf/datasets/rajpurkar/squad/resolve/main/plain_text/train-00000-of-00001.parquet
|
||||
```
|
||||
|
||||
#### Civitai
|
||||
|
||||
```url
|
||||
# AI model download original URL
|
||||
https://civitai.com/api/download/models/128713
|
||||
|
||||
# Transformed (add civitai prefix)
|
||||
https://xget.xi-xu.me/civitai/api/download/models/128713
|
||||
|
||||
# Model API original URL
|
||||
https://civitai.com/api/v1/models/7240
|
||||
|
||||
# Transformed (add civitai prefix)
|
||||
https://xget.xi-xu.me/civitai/api/v1/models/7240
|
||||
|
||||
# Model version API original URL
|
||||
https://civitai.com/api/v1/model-versions/128713
|
||||
|
||||
# Transformed (add civitai prefix)
|
||||
https://xget.xi-xu.me/civitai/api/v1/model-versions/128713
|
||||
```
|
||||
|
||||
#### npm
|
||||
|
||||
```url
|
||||
@@ -568,6 +592,48 @@ print("Model and tokenizer loaded successfully!")
|
||||
# print(tokenizer.decode(chat_history_ids[:, new_user_input_ids.shape[-1]:][0], skip_special_tokens=True))
|
||||
```
|
||||
|
||||
### Civitai AI Model Platform
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
# Set API base URL to use Xget acceleration
|
||||
base_url = "https://xget.xi-xu.me/civitai"
|
||||
|
||||
# Get model information
|
||||
def get_model_info(model_id):
|
||||
"""Retrieve Civitai model information"""
|
||||
url = f"{base_url}/api/v1/models/{model_id}"
|
||||
response = requests.get(url)
|
||||
return response.json()
|
||||
|
||||
# Download model
|
||||
def download_model(model_version_id, output_path):
|
||||
"""Download Civitai model file"""
|
||||
download_url = f"{base_url}/api/download/models/{model_version_id}"
|
||||
|
||||
print(f"Downloading model version {model_version_id}...")
|
||||
|
||||
response = requests.get(download_url, stream=True)
|
||||
response.raise_for_status()
|
||||
|
||||
with open(output_path, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
|
||||
print(f"Model downloaded to: {output_path}")
|
||||
|
||||
# Usage example
|
||||
model_id = 7240 # Example model ID
|
||||
model_info = get_model_info(model_id)
|
||||
print(f"Model name: {model_info['name']}")
|
||||
|
||||
# Download the first model version
|
||||
if model_info['modelVersions']:
|
||||
version_id = model_info['modelVersions'][0]['id']
|
||||
download_model(version_id, f"model_{version_id}.safetensors")
|
||||
```
|
||||
|
||||
### npm Package Acceleration
|
||||
|
||||
#### Configure npm to use Xget mirror
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
[](#sourceforge)
|
||||
[](#aosp-android-%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE)
|
||||
[](#hugging-face-镜像)
|
||||
[](#civitai-ai-模型平台)
|
||||
[](#npm-包管理加速)
|
||||
[](#python-包管理加速)
|
||||
[](#conda-包管理加速)
|
||||
@@ -138,6 +139,7 @@
|
||||
| SourceForge | `sf` | `https://sourceforge.net/...` | `https://xget.xi-xu.me/sf/...` |
|
||||
| AOSP | `aosp` | `https://android.googlesource.com/...` | `https://xget.xi-xu.me/aosp/...` |
|
||||
| Hugging Face | `hf` | `https://huggingface.co/...` | `https://xget.xi-xu.me/hf/...` |
|
||||
| Civitai | `civitai` | `https://civitai.com/...` | `https://xget.xi-xu.me/civitai/...` |
|
||||
| npm | `npm` | `https://registry.npmjs.org/...` | `https://xget.xi-xu.me/npm/...` |
|
||||
| PyPI | `pypi` | `https://pypi.org/...` | `https://xget.xi-xu.me/pypi/...` |
|
||||
| conda | `conda` | `https://repo.anaconda.com/...` 和 `https://conda.anaconda.org/...` | `https://xget.xi-xu.me/conda/...` 和 `https://xget.xi-xu.me/conda/community/...` |
|
||||
@@ -248,6 +250,28 @@ https://huggingface.co/datasets/rajpurkar/squad/resolve/main/plain_text/train-00
|
||||
https://xget.xi-xu.me/hf/datasets/rajpurkar/squad/resolve/main/plain_text/train-00000-of-00001.parquet
|
||||
```
|
||||
|
||||
#### Civitai
|
||||
|
||||
```url
|
||||
# AI 模型下载原始 URL
|
||||
https://civitai.com/api/download/models/128713
|
||||
|
||||
# 转换后(添加 civitai 前缀)
|
||||
https://xget.xi-xu.me/civitai/api/download/models/128713
|
||||
|
||||
# 模型 API 原始 URL
|
||||
https://civitai.com/api/v1/models/7240
|
||||
|
||||
# 转换后(添加 civitai 前缀)
|
||||
https://xget.xi-xu.me/civitai/api/v1/models/7240
|
||||
|
||||
# 模型版本 API 原始 URL
|
||||
https://civitai.com/api/v1/model-versions/128713
|
||||
|
||||
# 转换后(添加 civitai 前缀)
|
||||
https://xget.xi-xu.me/civitai/api/v1/model-versions/128713
|
||||
```
|
||||
|
||||
#### npm
|
||||
|
||||
```url
|
||||
@@ -812,6 +836,48 @@ print("模型和分词器加载成功!")
|
||||
# print(tokenizer.decode(chat_history_ids[:, new_user_input_ids.shape[-1]:][0], skip_special_tokens=True))
|
||||
```
|
||||
|
||||
### Civitai AI 模型平台
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
# 设置 API 基础 URL 使用 Xget 加速
|
||||
base_url = "https://xget.xi-xu.me/civitai"
|
||||
|
||||
# 获取模型信息
|
||||
def get_model_info(model_id):
|
||||
"""获取 Civitai 模型信息"""
|
||||
url = f"{base_url}/api/v1/models/{model_id}"
|
||||
response = requests.get(url)
|
||||
return response.json()
|
||||
|
||||
# 下载模型
|
||||
def download_model(model_version_id, output_path):
|
||||
"""下载 Civitai 模型文件"""
|
||||
download_url = f"{base_url}/api/download/models/{model_version_id}"
|
||||
|
||||
print(f"正在下载模型版本 {model_version_id}...")
|
||||
|
||||
response = requests.get(download_url, stream=True)
|
||||
response.raise_for_status()
|
||||
|
||||
with open(output_path, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
|
||||
print(f"模型已下载到: {output_path}")
|
||||
|
||||
# 使用示例
|
||||
model_id = 7240 # 示例模型 ID
|
||||
model_info = get_model_info(model_id)
|
||||
print(f"模型名称: {model_info['name']}")
|
||||
|
||||
# 下载第一个模型版本
|
||||
if model_info['modelVersions']:
|
||||
version_id = model_info['modelVersions'][0]['id']
|
||||
download_model(version_id, f"model_{version_id}.safetensors")
|
||||
```
|
||||
|
||||
### npm 包管理加速
|
||||
|
||||
#### 配置 npm 使用 Xget 镜像
|
||||
|
||||
Reference in new issue
Block a user