Xenova HF staff commited on
Commit
b7a5988
·
1 Parent(s): 4a164d9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -0
README.md CHANGED
@@ -4,4 +4,29 @@ library_name: transformers.js
4
 
5
  https://huggingface.co/nvidia/mit-b2 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/nvidia/mit-b2 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:** Perform image classification with `Xenova/mit-b2`.
16
+
17
+ ```js
18
+ import { pipeline } from '@xenova/transformers';
19
+
20
+ // Create image classification pipeline
21
+ const classifier = await pipeline('image-classification', 'Xenova/mit-b2');
22
+
23
+ // Classify an image
24
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg';
25
+ const output = await classifier(url);
26
+ console.log(output)
27
+ // [{ label: 'tiger, Panthera tigris', score: 0.761507511138916 }]
28
+ ```
29
+
30
+ ---
31
+
32
  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`).