Xenova HF staff commited on
Commit
e6e86e6
1 Parent(s): c9186c2

Update to Transformers.js v3

Browse files
Files changed (1) hide show
  1. README.md +4 -4
README.md CHANGED
@@ -7,7 +7,7 @@ https://huggingface.co/nielsr/slimsam-77-uniform with ONNX weights to be compati
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
  ```
@@ -15,7 +15,7 @@ npm i @xenova/transformers
15
  **Example:** Perform mask generation with `Xenova/slimsam-77-uniform`.
16
 
17
  ```js
18
- import { SamModel, AutoProcessor, RawImage } from '@xenova/transformers';
19
 
20
  // Load model and processor
21
  const model = await SamModel.from_pretrained('Xenova/slimsam-77-uniform');
@@ -24,10 +24,10 @@ const processor = await AutoProcessor.from_pretrained('Xenova/slimsam-77-uniform
24
  // Prepare image and input points
25
  const img_url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/corgi.jpg';
26
  const raw_image = await RawImage.read(img_url);
27
- const input_points = [[[340, 250]]] // 2D localization of a window
28
 
29
  // Process inputs and perform mask generation
30
- const inputs = await processor(raw_image, input_points);
31
  const outputs = await model(inputs);
32
 
33
  // Post-process masks
 
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/@huggingface/transformers) using:
11
  ```bash
12
  npm i @xenova/transformers
13
  ```
 
15
  **Example:** Perform mask generation with `Xenova/slimsam-77-uniform`.
16
 
17
  ```js
18
+ import { SamModel, AutoProcessor, RawImage } from '@huggingface/transformers';
19
 
20
  // Load model and processor
21
  const model = await SamModel.from_pretrained('Xenova/slimsam-77-uniform');
 
24
  // Prepare image and input points
25
  const img_url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/corgi.jpg';
26
  const raw_image = await RawImage.read(img_url);
27
+ const input_points = [[[340, 250]]];
28
 
29
  // Process inputs and perform mask generation
30
+ const inputs = await processor(raw_image, { input_points });
31
  const outputs = await model(inputs);
32
 
33
  // Post-process masks