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