Xenova HF staff commited on
Commit
b807cea
1 Parent(s): 358216f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -0
README.md CHANGED
@@ -4,4 +4,32 @@ library_name: transformers.js
4
 
5
  https://huggingface.co/google/owlv2-base-patch16-ensemble 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/google/owlv2-base-patch16-ensemble with ONNX weights to be compatible with Transformers.js.
6
 
7
+
8
+ ## Usage (Transformers.js)
9
+
10
+ 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:
11
+ ```bash
12
+ npm i @xenova/transformers
13
+ ```
14
+
15
+ **Example:** Zero-shot object detection w/ `Xenova/owlv2-base-patch16-ensemble`.
16
+ ```js
17
+ import { pipeline } from '@xenova/transformers';
18
+
19
+ const detector = await pipeline('zero-shot-object-detection', 'Xenova/owlv2-base-patch16-ensemble');
20
+
21
+ const url = 'http://images.cocodataset.org/val2017/000000039769.jpg';
22
+ const candidate_labels = ['a photo of a cat', 'a photo of a dog'];
23
+ const output = await detector(url, candidate_labels);
24
+ console.log(output);
25
+ // [
26
+ // { score: 0.7400985360145569, label: 'a photo of a cat', box: { xmin: 0, ymin: 50, xmax: 323, ymax: 485 } },
27
+ // { score: 0.6315087080001831, label: 'a photo of a cat', box: { xmin: 333, ymin: 23, xmax: 658, ymax: 378 } }
28
+ // ]
29
+ ```
30
+
31
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/SwSILPFpBGNE39J3uwXWN.png)
32
+
33
+ ---
34
+
35
  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`).