Xenova HF Staff commited on
Commit
ed5c645
·
verified ·
1 Parent(s): 0b95b21

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -0
README.md CHANGED
@@ -4,4 +4,25 @@ library_name: "transformers.js"
4
 
5
  https://huggingface.co/openai/clip-vit-base-patch32 with ONNX weights to be compatible with Transformers.js.
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).
 
4
 
5
  https://huggingface.co/openai/clip-vit-base-patch32 with ONNX weights to be compatible with Transformers.js.
6
 
7
+ ## Usage (Transformers.js)
8
+
9
+ 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/@xenova/transformers) using:
10
+ ```bash
11
+ npm i @xenova/transformers
12
+ ```
13
+
14
+ **Example:** Perform zero-shot image classification with the `pipeline` API.
15
+ ```js
16
+ const classifier = await pipeline('zero-shot-image-classification', 'Xenova/clip-vit-base-patch32');
17
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg';
18
+ const output = await classifier(url, ['tiger', 'horse', 'dog']);
19
+ // [
20
+ // { score: 0.9993917942047119, label: 'tiger' },
21
+ // { score: 0.0003519294841680676, label: 'horse' },
22
+ // { score: 0.0002562698791734874, label: 'dog' }
23
+ // ]
24
+ ```
25
+
26
+ ---
27
+
28
  Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).