Skip to content

Commit e8c190a

Browse files
committed
update readme
1 parent 09fbf86 commit e8c190a

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
本项目依托fastchat的基础能力来提供**openai server**的能力.
1616

17-
1. 支持**Chat****Embedding****ReRanker****text-moderation(文本审核,分类)****ASR****TTS(支持声音克隆)** 模型的 **openai**规范 接口服务。
17+
1. 支持**Chat****Embedding****ReRanker****text-moderation(文本审核,分类)****ASR****TTS(支持声音克隆)****SD(Stable Diffusion,文生图)** 模型的 **openai**规范 接口服务。
1818
2. 支持**HF****vLLM****LMDeploy****SGLang** 多种加速推理后端引擎。
1919
3. 多个模型共用**openai server**的同一个端口进行调用,自动进行模型调度。
2020

@@ -30,6 +30,7 @@
3030
| 🎛️ | **Text-moderation(文本审核,分类)** | 支持`OpenAI` 服务接口规范的文本审核,分类 |
3131
| 📱 | **ASR(语音转文本)** | 支持基于`FunASR`的ASR模型 |
3232
| 🔊 | **TTS(文本转语音)** | 支持基于`SparkTTS`的TTS模型,支持基于`vLLM``SGLang`后端对齐加速,`RTF<<1`,支持流式音频流输出 |
33+
| 🖌️ | **SD(Stable Diffusion,文生图)** | 支持基于`diffusers``文生图` 模型 |
3334
| 🔄 | **支持LM/VL模型** | 支持多种大语言模型或多模态语言模型 |
3435
| 🎭 | **推理服务性能测试** | 基于`Evalscope`实现`Throughput``TTFT``TPOT`等服务性能指标 |
3536

@@ -42,6 +43,7 @@
4243
- 全球唯一支持了**openai**库的文本审核模型接口(text-moderation, /v1/moderations)。(代码样例见gpt_server/tests/test_openai_moderation.py)
4344
- 全球唯一支持了**openai**库的TTS模型接口(tts, /v1/audio/speech)(代码样例见gpt_server/tests/test_openai_tts_stream.py)
4445
- 全球唯一支持了**openai**库的ASR模型接口(asr, /v1/audio/transcriptions),基于fanasr后端(代码样例见gpt_server/tests/test_openai_transcriptions.py)
46+
- 全球唯一支持了**openai**库的SD,文生图模型接口(sd, /v1/images/generations),基于diffusers后端(代码样例见gpt_server/tests/test_image_gen.py)
4547

4648
## 🖼️ 配置文档
4749
通过这个样例文件,可以很快的掌握项目的配置方式。
@@ -53,6 +55,7 @@
5355
<summary><b>2025</b></summary>
5456

5557
```plaintext
58+
2025-6-12 支持了 文生图模型 flux (代码样例见gpt_server/tests/test_image_gen.py)
5659
2025-6-6 支持了 bge-vl 系列 (代码样例见gpt_server/tests/test_openai_embedding_vl.py)
5760
2025-6-6 支持了 ritrieve_zh_v1
5861
2025-4-29 支持了 Qwen3
@@ -120,7 +123,7 @@
120123
* [X] 支持Reranker模型动态组批(实现方式:infinity后端)
121124
* [X] 可视化启动界面(不稳定,对开发人员来说比较鸡肋,后期将弃用!)
122125
* [X] 并行的function call功能(tools)
123-
* [ ] 支持 文生图模型
126+
* [X] 支持 文生图 模型
124127
* [ ] 支持 pip install 方式进行安装
125128

126129

gpt_server/model_worker/base/model_worker_base.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ def get_model_class(self):
119119

120120
def load_model_tokenizer(self, model_path):
121121
"""加载 模型 和 分词器 直接对 self.model 和 self.tokenizer 进行赋值"""
122-
if (
123-
self.model_type == "embedding"
124-
or self.model_type == "asr"
125-
or self.model_type == "tts"
126-
):
122+
if self.model_type in ["embedding", "asr", "tts", "image"]:
127123
return 1
128124
self.tokenizer = AutoTokenizer.from_pretrained(
129125
model_path,

gpt_server/openai_api_protocol/custom_api_protocol.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
class ImagesGenRequest(BaseModel):
1818
prompt: str
1919
model: str
20-
output_format: str # png, jpeg, or webp
20+
output_format: Literal["png", "jpeg", "webp"] = Field(
21+
default="png",
22+
description="png, jpeg, or webp",
23+
)
2124

2225

2326
# copy from https://github.com/remsky/Kokoro-FastAPI/blob/master/api/src/routers/openai_compatible.py

gpt_server/script/config_example.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,16 @@ models:
156156
workers:
157157
- gpus:
158158
- 6
159+
160+
- flux:
161+
#文生图模型
162+
alias: null
163+
enable: true
164+
model_config:
165+
model_name_or_path: /home/dev/model/MusePublic/489_ckpt_FLUX_1/
166+
model_type: flux
167+
work_mode: hf
168+
device: gpu
169+
workers:
170+
- gpus:
171+
- 7

tests/test_image_gen.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import base64
2+
from openai import OpenAI
3+
4+
client = OpenAI(api_key="EMPTY", base_url="http://localhost:8082/v1")
5+
6+
img = client.images.generate(model="flux", prompt="A red pig")
7+
8+
image_bytes = base64.b64decode(img.data[0].b64_json)
9+
with open("output.png", "wb") as f:
10+
f.write(image_bytes)

0 commit comments

Comments
 (0)