Update README.md
Browse files
README.md
CHANGED
@@ -4,4 +4,33 @@ library_name: transformers.js
|
|
4 |
|
5 |
https://huggingface.co/facebook/hiera-tiny-224-in1k-hf 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/facebook/hiera-tiny-224-in1k-hf 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/@huggingface/transformers) using:
|
10 |
+
```bash
|
11 |
+
npm i @huggingface/transformers
|
12 |
+
```
|
13 |
+
|
14 |
+
**Example:** Perform image classification with `onnx-community/hiera-tiny-224-in1k-hf`
|
15 |
+
```js
|
16 |
+
import { pipeline } from '@huggingface/transformers';
|
17 |
+
|
18 |
+
// Create an image classification pipeline
|
19 |
+
const classifier = await pipeline('image-classification', 'onnx-community/hiera-tiny-224-in1k-hf');
|
20 |
+
|
21 |
+
// Classify an image
|
22 |
+
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg';
|
23 |
+
const output = await classifier(url);
|
24 |
+
console.log(output);
|
25 |
+
// [
|
26 |
+
// { label: 'tiger, Panthera tigris', score: 0.759323239326477 },
|
27 |
+
// { label: 'tiger cat', score: 0.08907650411128998 },
|
28 |
+
// { label: 'lynx, catamount', score: 0.0008640264859423041 },
|
29 |
+
// { label: 'jaguar, panther, Panthera onca, Felis onca', score: 0.0007982379174791276 },
|
30 |
+
// { label: 'leopard, Panthera pardus', score: 0.00041627752943895757 }
|
31 |
+
// ]
|
32 |
+
```
|
33 |
+
|
34 |
+
---
|
35 |
+
|
36 |
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`).
|