Update README.md
Browse files
README.md
CHANGED
@@ -4,4 +4,32 @@ library_name: transformers.js
|
|
4 |
|
5 |
https://huggingface.co/google/owlv2-base-patch16-finetuned 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-finetuned 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-finetuned`.
|
16 |
+
```js
|
17 |
+
import { pipeline } from '@xenova/transformers';
|
18 |
+
|
19 |
+
const detector = await pipeline('zero-shot-object-detection', 'Xenova/owlv2-base-patch16-finetuned');
|
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.6951543688774109, label: 'a photo of a cat', box: { xmin: 326, ymin: 23, xmax: 650, ymax: 376 } },
|
27 |
+
// { score: 0.5766839385032654, label: 'a photo of a cat', box: { xmin: 6, ymin: 63, xmax: 315, ymax: 487 } }
|
28 |
+
// ]
|
29 |
+
```
|
30 |
+
|
31 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/yesvZXyal8RGtNZ5Diuma.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`).
|