Skip to content

Commit f0ff09c

Browse files
authored
Oml zoo (#291)
* Support of Qdrant/Unicom-ViT-B-16 and Qdrant/Unicom-ViT-B-32
1 parent d09af55 commit f0ff09c

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

fastembed/image/image_embedding.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def __init__(
6565
return
6666

6767
raise ValueError(
68-
f"Model {model_name} is not supported in TextEmbedding."
69-
"Please check the supported models using `TextEmbedding.list_supported_models()`"
68+
f"Model {model_name} is not supported in ImageEmbedding."
69+
"Please check the supported models using `ImageEmbedding.list_supported_models()`"
7070
)
7171

7272
def embed(

fastembed/image/onnx_embedding.py

+29-4
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,28 @@
2929
},
3030
"model_file": "model.onnx",
3131
},
32+
{
33+
"model": "Qdrant/Unicom-ViT-B-16",
34+
"dim": 768,
35+
"description": "Unicom Unicom-ViT-B-16 from open-metric-learning",
36+
"size_in_GB": 0.82,
37+
"sources": {
38+
"hf": "Qdrant/Unicom-ViT-B-16",
39+
},
40+
"model_file": "model.onnx",
41+
},
42+
{
43+
"model": "Qdrant/Unicom-ViT-B-32",
44+
"dim": 512,
45+
"description": "Unicom Unicom-ViT-B-32 from open-metric-learning",
46+
"size_in_GB": 0.48,
47+
"sources": {
48+
"hf": "Qdrant/Unicom-ViT-B-32",
49+
},
50+
"model_file": "model.onnx",
51+
},
3252
]
3353

34-
3554
class OnnxImageEmbedding(ImageEmbeddingBase, OnnxImageModel[np.ndarray]):
3655
def __init__(
3756
self,
@@ -122,10 +141,16 @@ def _preprocess_onnx_input(
122141

123142
return onnx_input
124143

125-
def _post_process_onnx_output(self, output: OnnxOutputContext) -> Iterable[np.ndarray]:
144+
def _post_process_onnx_output(
145+
self, output: OnnxOutputContext
146+
) -> Iterable[np.ndarray]:
126147
return normalize(output.model_output).astype(np.float32)
127148

128149

129150
class OnnxImageEmbeddingWorker(ImageEmbeddingWorker):
130-
def init_embedding(self, model_name: str, cache_dir: str, **kwargs) -> OnnxImageEmbedding:
131-
return OnnxImageEmbedding(model_name=model_name, cache_dir=cache_dir, threads=1, **kwargs)
151+
def init_embedding(
152+
self, model_name: str, cache_dir: str, **kwargs
153+
) -> OnnxImageEmbedding:
154+
return OnnxImageEmbedding(
155+
model_name=model_name, cache_dir=cache_dir, threads=1, **kwargs
156+
)

tests/test_image_onnx_embeddings.py

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
"Qdrant/resnet50-onnx": np.array(
1212
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01046245, 0.01171397, 0.00705971, 0.0]
1313
),
14+
"Qdrant/Unicom-ViT-B-16": np.array(
15+
[ 0.0170, -0.0361, 0.0125, -0.0428, -0.0232, 0.0232, -0.0602, -0.0333,
16+
0.0155, 0.0497]
17+
),
18+
"Qdrant/Unicom-ViT-B-32": np.array(
19+
[0.0418, 0.0550, 0.0003, 0.0253, -0.0185, 0.0016, -0.0368, -0.0402,
20+
-0.0891, -0.0186]
21+
),
1422
}
1523

1624

0 commit comments

Comments
 (0)