CLIP ViT-B/32 ONNX
OpenAI's CLIP ViT-B/32, as separate image and text encoders in ONNX format for ONNX Runtime, float32.
These are unchanged copies of the ViT-B/32 files that clip-as-service downloads. Their MD5 match the checksums in clip-as-service's model list.
| File | Size | Use |
|---|---|---|
visual.onnx | 352 MB | image encoder: pixel_values (batch x 3 x 224 x 224, float32) |
textual.onnx | 254 MB | text encoder: input_ids and attention_mask (batch x tokens, int32) |
MANIFEST.json lists each file's size and SHA-256.
Use with ONNX Runtime
Images are resized and centre-cropped to 224 x 224, scaled to 0-1 and normalised with CLIP's mean
(0.48145466, 0.4578275, 0.40821073) and standard deviation (0.26862954, 0.26130258, 0.27577711).
Text is tokenized with CLIP's BPE tokenizer, padded to 77 tokens. Each encoder returns one
512-value embedding per input (output); normalise them and compare with a dot product.
import onnxruntime as ort
visual = ort.InferenceSession("visual.onnx", providers=["CPUExecutionProvider"])
textual = ort.InferenceSession("textual.onnx", providers=["CPUExecutionProvider"])
image_embedding = visual.run(None, {"pixel_values": pixels})[0]
text_embedding = textual.run(None, {"input_ids": ids, "attention_mask": mask})[0]
Source
| Model | CLIP ViT-B/32, openai/CLIP |
| Files | clip-as-service model store: https://clip-as-service.s3.us-east-2.amazonaws.com/models-436c69702d61732d53657276696365/onnx/ViT-B-32/visual.onnx and .../textual.onnx |
License
The CLIP weights are under the MIT License of openai/CLIP; a copy is in LICENSE. clip-as-service, which made the ONNX export, is under the Apache License 2.0; a copy is in LICENSE-clip-as-service.