---
title: MobileCLIP-ONNX
canonical_url: "https://www.modelscope.cn/models/budaoshou/MobileCLIP-ONNX"
md_url: "https://www.modelscope.cn/models/budaoshou/MobileCLIP-ONNX.md"
repository: budaoshou/MobileCLIP-ONNX
chinese_name: MobileCLIP-ONNX
last_updated: 2026-06-30
license: other
model_type:
  - clip
library_name:
  - onnx
  - pytorch
frameworks:
  - Pytorch
downloads: 0
stars: 0
tags:
  - mobileclip
  - image-feature-extraction
  - feature-extraction
---

# MobileCLIP-ONNX

> MobileCLIP-ONNX - budaoshou 在 ModelScope 开源的模型。https://github.com/apple/ml-mobileclip with ONNX weights to be compatible with Transformers.js.

budaoshou/MobileCLIP-ONNX 是 ModelScope 魔搭社区上的机器学习模型，采用 other 许可。

- **Repository**: budaoshou/MobileCLIP-ONNX
- **License**: other
- **Tags**: mobileclip, image-feature-extraction, feature-extraction
- **Downloads**: 0
- **Stars**: 0
- **Last updated**: 2026-06-30

Source: https://www.modelscope.cn/models/budaoshou/MobileCLIP-ONNX

---

https://github.com/apple/ml-mobileclip with ONNX weights to be compatible with Transformers.js.

## Usage (Transformers.js)

If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@huggingface/transformers) using:
```bash
npm i @huggingface/transformers
```

**Example:** Perform zero-shot image classification.
```js
import {
  AutoTokenizer,
  CLIPTextModelWithProjection,
  AutoProcessor,
  CLIPVisionModelWithProjection,
  RawImage,
  dot,
  softmax,
} from '@huggingface/transformers';

const model_id = 'Xenova/mobileclip_s2';

// Load tokenizer and text model
const tokenizer = await AutoTokenizer.from_pretrained(model_id);
const text_model = await CLIPTextModelWithProjection.from_pretrained(model_id);

// Load processor and vision model
const processor = await AutoProcessor.from_pretrained(model_id);
const vision_model = await CLIPVisionModelWithProjection.from_pretrained(model_id);

// Run tokenization
const texts = ['cats', 'dogs', 'birds'];
const text_inputs = tokenizer(texts, { padding: 'max_length', truncation: true });

// Compute text embeddings
const { text_embeds } = await text_model(text_inputs);
const normalized_text_embeds = text_embeds.normalize().tolist();

// Read image and run processor
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg';
const image = await RawImage.read(url);
const image_inputs = await processor(image);

// Compute vision embeddings
const { image_embeds } = await vision_model(image_inputs);
const normalized_image_embeds = image_embeds.normalize().tolist();

// Compute probabilities
const probabilities = normalized_image_embeds.map(
  x => softmax(normalized_text_embeds.map(y => 100 * dot(x, y)))
);
console.log(probabilities); // [[ 0.9999973851268408, 0.000002399646544186113, 2.1522661499262862e-7 ]]
```
