docs: update README with API and deployment guide

This commit is contained in:
yumoqing 2026-07-21 17:39:26 +08:00
parent a71c52a69d
commit ee63e7194c

View File

@ -1,52 +1,42 @@
# CLIP Embedding Service # CLIP Embedding — 多模态向量化服务
CLIP-ViT-H/14 多模态 Embedding 服务,支持文本和图片向量化。 ## 概述
## Overview 基于 OpenAI CLIP ViT-H-14 的多模态嵌入服务,将文本和图像编码为统一的 1024 维向量空间,实现图文跨模态检索。
- **Model**: laion/CLIP-ViT-H-14-laion2B-s32B-b79K ## 模型
- **Dimension**: 1024
- **Precision**: float16 - BAAI/CLIP-ViT-H-14 (OpenCLIP)
- **Port**: 9086 - 向量维度: 1024
- **GPU**: 2 (default) - GPU: 部署于 GPU 服务器
## API ## API
### GET /api/status | 端点 | 方法 | 说明 |
Service health and GPU info. |------|------|------|
| /api/status | GET | 服务状态和模型信息 |
| /api/text | POST | 文本 → 向量 |
| /api/image | POST | 图片 → 向量 |
| /api/similarity | POST | 文本-图片相似度计算 |
## 请求示例
### POST /api/text
Text embedding.
```json ```json
{"texts": ["hello world", "a cat"]} POST /api/text
{"texts": ["一只猫坐在沙发上", "日落海滩"]}
POST /api/image
{"images": ["base64图片数据"]}
``` ```
### POST /api/image ## 部署
Image embedding (file path, URL, or base64 data URI).
```json
{"images": ["/path/to/img.jpg", "https://example.com/img.png"]}
```
### POST /api/embed
Combined text + image embedding.
```json
{"texts": ["a cat"], "images": ["/path/to/cat.jpg"]}
```
## Model Download (Offline Deploy)
```bash ```bash
pip install huggingface_hub cd /data/ymq/clip_embedding
huggingface-cli download laion/CLIP-ViT-H-14-laion2B-s32B-b79K \ bash build.sh
--local-dir /data/ymq/models/laion/CLIP-ViT-H-14-laion2B-s32B-b79K \ sudo systemctl restart clip
--local-dir-use-symlinks False
``` ```
Size: ~15GB
## Deploy ## 端口
```bash 9086
bash build.sh deploy # start
bash build.sh stop # stop
bash build.sh status # check
```