c10f90fe
tangwang
cnclip
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
"""
Protocols for embedding backends (structural typing, no inheritance required).
Used by the embedding service so that any backend (ClipAsServiceImageEncoder,
ClipImageModel, etc.) can be used as long as it implements the same interface.
"""
from typing import List, Optional, Protocol
import numpy as np
class ImageEncoderProtocol(Protocol):
"""Contract for image encoders used by the embedding service /embed/image endpoint."""
def encode_image_urls(
self,
urls: List[str],
batch_size: Optional[int] = None,
|
7a013ca7
tangwang
多模态文本向量服务ok
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
def encode_clip_texts(
self,
texts: List[str],
batch_size: Optional[int] = None,
normalize_embeddings: bool = True,
) -> List[np.ndarray]:
"""
Encode natural-language strings with the CLIP/CN-CLIP text tower (same space as images).
Returns:
List of vectors, same length as texts.
"""
...
|