Update README.md
Browse files
README.md
CHANGED
@@ -4,7 +4,6 @@ library_name: transformers.js
|
|
4 |
|
5 |
https://huggingface.co/nielsr/slimsam-77-uniform 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:
|
@@ -55,9 +54,21 @@ console.log(scores);
|
|
55 |
// }
|
56 |
```
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
![image/gif](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/ATwz4cQEZyUwU2BsOTq92.gif)
|
59 |
|
60 |
|
|
|
61 |
## Demo
|
62 |
|
63 |
We've also got an online demo, which you can try out [here](https://huggingface.co/spaces/Xenova/segment-anything-web).
|
|
|
4 |
|
5 |
https://huggingface.co/nielsr/slimsam-77-uniform 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/@xenova/transformers) using:
|
|
|
54 |
// }
|
55 |
```
|
56 |
|
57 |
+
You can then visualize the generated mask with:
|
58 |
+
|
59 |
+
```js
|
60 |
+
const image = RawImage.fromTensor(masks[0][0].mul(255));
|
61 |
+
image.save('mask.png');
|
62 |
+
```
|
63 |
+
|
64 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/2vWMNptPh5jJKdLrnUIik.png)
|
65 |
+
|
66 |
+
Next, select the channel with the highest IoU score, which in this case is the second (green) channel. Intersecting this with the original image gives us an isolated version of the subject:
|
67 |
+
|
68 |
![image/gif](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/ATwz4cQEZyUwU2BsOTq92.gif)
|
69 |
|
70 |
|
71 |
+
|
72 |
## Demo
|
73 |
|
74 |
We've also got an online demo, which you can try out [here](https://huggingface.co/spaces/Xenova/segment-anything-web).
|