Transformers.js v3.5 optimizations
Browse files
README.md
CHANGED
|
@@ -12,9 +12,9 @@ https://github.com/apple/ml-mobileclip with ONNX weights to be compatible with T
|
|
| 12 |
|
| 13 |
## Usage (Transformers.js)
|
| 14 |
|
| 15 |
-
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/@
|
| 16 |
```bash
|
| 17 |
-
npm i @
|
| 18 |
```
|
| 19 |
|
| 20 |
**Example:** Perform zero-shot image classification.
|
|
@@ -27,7 +27,7 @@ import {
|
|
| 27 |
RawImage,
|
| 28 |
dot,
|
| 29 |
softmax,
|
| 30 |
-
} from '@
|
| 31 |
|
| 32 |
const model_id = 'Xenova/mobileclip_blt';
|
| 33 |
|
|
@@ -37,9 +37,7 @@ const text_model = await CLIPTextModelWithProjection.from_pretrained(model_id);
|
|
| 37 |
|
| 38 |
// Load processor and vision model
|
| 39 |
const processor = await AutoProcessor.from_pretrained(model_id);
|
| 40 |
-
const vision_model = await CLIPVisionModelWithProjection.from_pretrained(model_id
|
| 41 |
-
quantized: false, // NOTE: vision model is sensitive to quantization.
|
| 42 |
-
});
|
| 43 |
|
| 44 |
// Run tokenization
|
| 45 |
const texts = ['cats', 'dogs', 'birds'];
|
|
|
|
| 12 |
|
| 13 |
## Usage (Transformers.js)
|
| 14 |
|
| 15 |
+
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:
|
| 16 |
```bash
|
| 17 |
+
npm i @huggingface/transformers
|
| 18 |
```
|
| 19 |
|
| 20 |
**Example:** Perform zero-shot image classification.
|
|
|
|
| 27 |
RawImage,
|
| 28 |
dot,
|
| 29 |
softmax,
|
| 30 |
+
} from '@huggingface/transformers';
|
| 31 |
|
| 32 |
const model_id = 'Xenova/mobileclip_blt';
|
| 33 |
|
|
|
|
| 37 |
|
| 38 |
// Load processor and vision model
|
| 39 |
const processor = await AutoProcessor.from_pretrained(model_id);
|
| 40 |
+
const vision_model = await CLIPVisionModelWithProjection.from_pretrained(model_id);
|
|
|
|
|
|
|
| 41 |
|
| 42 |
// Run tokenization
|
| 43 |
const texts = ['cats', 'dogs', 'birds'];
|