Update README.md
Browse files
README.md
CHANGED
@@ -1,39 +1,115 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
+
# Welcome to CLIP-as-service!
|
5 |
+
|
6 |
+
CLIP-as-service is a low-latency high-scalability service for embedding images and text. It can be easily integrated as a microservice into neural search solutions.
|
7 |
+
|
8 |
+
โก Fast: Serve CLIP models with TensorRT, ONNX runtime and PyTorch w/o JIT with 800QPS[*]. Non-blocking duplex streaming on requests and responses, designed for large data and long-running tasks.
|
9 |
+
|
10 |
+
๐ซ Elastic: Horizontally scale up and down multiple CLIP models on single GPU, with automatic load balancing.
|
11 |
+
|
12 |
+
๐ฅ Easy-to-use: No learning curve, minimalist design on client and server. Intuitive and consistent API for image and sentence embedding.
|
13 |
+
|
14 |
+
๐ Modern: Async client support. Easily switch between gRPC, HTTP, WebSocket protocols with TLS and compression.
|
15 |
+
|
16 |
+
๐ฑ Integration: Smooth integration with neural search ecosystem including Jina and DocArray. Build cross-modal and multi-modal solutions in no time.
|
17 |
+
|
18 |
+
[*] with default config (single replica, PyTorch no JIT) on GeForce RTX 3090.
|
19 |
+
|
20 |
+
## Try it!
|
21 |
+
|
22 |
+
## Install
|
23 |
+
|
24 |
+
[PyPI](https://img.shields.io/pypi/v/clip_client?color=%23ffffff&label=%20) is the latest version.
|
25 |
+
|
26 |
+
Make sure you are using Python 3.7+. You can install the client and server independently. It is **not required** to install both: e.g. you can install `clip_server` on a GPU machine and `clip_client` on a local laptop.
|
27 |
+
|
28 |
+
Client
|
29 |
+
|
30 |
+
```bash
|
31 |
+
pip install clip-client
|
32 |
+
```
|
33 |
+
|
34 |
+
Server (PyTorch)
|
35 |
+
|
36 |
+
```
|
37 |
+
pip install clip-server
|
38 |
+
```
|
39 |
+
Server (ONNX)
|
40 |
+
|
41 |
+
```
|
42 |
+
pip install "clip_server[onnx]"
|
43 |
+
```
|
44 |
+
Server (TensorRT)
|
45 |
+
|
46 |
+
```
|
47 |
+
pip install nvidia-pyindex
|
48 |
+
pip install "clip_server[tensorrt]"
|
49 |
+
```
|
50 |
+
Server on [Google Colab](https://colab.research.google.com/github/jina-ai/clip-as-service/blob/main/docs/hosting/cas-on-colab.ipynb)
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
## Quick check
|
55 |
+
|
56 |
+
After installing, you can run the following commands for a quick connectivity check.
|
57 |
+
|
58 |
+
### Start the server
|
59 |
+
|
60 |
+
Start PyTorch Server
|
61 |
+
```bash
|
62 |
+
python -m clip_server
|
63 |
+
```
|
64 |
+
Start ONNX Server
|
65 |
+
```bash
|
66 |
+
python -m clip_server onnx-flow.yml
|
67 |
+
```
|
68 |
+
Start TensorRT Server
|
69 |
+
```bash
|
70 |
+
python -m clip_server tensorrt-flow.yml
|
71 |
+
```
|
72 |
+
|
73 |
+
At the first time starting the server, it will download the default pretrained model, which may take a while depending on your network speed. Then you will get the address information similar to the following:
|
74 |
+
|
75 |
+
```text
|
76 |
+
โญโโโโโโโโโโโโโโ ๐ Endpoint โโโโโโโโโโโโโโโโฎ
|
77 |
+
โ ๐ Protocol GRPC โ
|
78 |
+
โ ๐ Local 0.0.0.0:51000 โ
|
79 |
+
โ ๐ Private 192.168.31.62:51000 โ
|
80 |
+
| ๐ Public 87.105.159.191:51000 |
|
81 |
+
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
|
82 |
+
```
|
83 |
+
|
84 |
+
This means the server is ready to serve. Note down the three addresses shown above, you will need them later.
|
85 |
+
|
86 |
+
### Connect from client
|
87 |
+
|
88 |
+
```{tip}
|
89 |
+
Depending on the location of the client and server. You may use different IP addresses:
|
90 |
+
- Client and server are on the same machine: use local address, e.g. `0.0.0.0`
|
91 |
+
- Client and server are connected to the same router: use private network address, e.g. `192.168.3.62`
|
92 |
+
- Server is in public network: use public network address, e.g. `87.105.159.191`
|
93 |
+
```
|
94 |
+
|
95 |
+
Run the following Python script:
|
96 |
+
|
97 |
+
```python
|
98 |
+
from clip_client import Client
|
99 |
+
|
100 |
+
c = Client('grpc://0.0.0.0:51000')
|
101 |
+
c.profile()
|
102 |
+
```
|
103 |
+
|
104 |
+
will give you:
|
105 |
+
|
106 |
+
```text
|
107 |
+
Roundtrip 16ms 100%
|
108 |
+
โโโ Client-server network 8ms 49%
|
109 |
+
โโโ Server 8ms 51%
|
110 |
+
โโโ Gateway-CLIP network 2ms 25%
|
111 |
+
โโโ CLIP model 6ms 75%
|
112 |
+
{'Roundtrip': 15.684750003856607, 'Client-server network': 7.684750003856607, 'Server': 8, 'Gateway-CLIP network': 2, 'CLIP model': 6}
|
113 |
+
```
|
114 |
+
|
115 |
+
It means the client and the server are now connected. Well done!
|