Update README.md
Browse files
README.md
CHANGED
|
@@ -5,4 +5,34 @@ base_model: facebook/dinov2-with-registers-large-imagenet1k-1-layer
|
|
| 5 |
|
| 6 |
https://huggingface.co/facebook/dinov2-with-registers-large-imagenet1k-1-layer with ONNX weights to be compatible with Transformers.js.
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
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`).
|
|
|
|
| 5 |
|
| 6 |
https://huggingface.co/facebook/dinov2-with-registers-large-imagenet1k-1-layer with ONNX weights to be compatible with Transformers.js.
|
| 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 @huggingface/transformers
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
**Example:** Image classification w/ `onnx-community/dinov2-with-registers-large-imagenet1k-1-layer`.
|
| 16 |
+
|
| 17 |
+
```javascript
|
| 18 |
+
import { pipeline } from '@huggingface/transformers';
|
| 19 |
+
|
| 20 |
+
// Create image classification pipeline
|
| 21 |
+
const classifier = await pipeline('image-classification', 'onnx-community/dinov2-with-registers-large-imagenet1k-1-layer');
|
| 22 |
+
|
| 23 |
+
// Classify an image
|
| 24 |
+
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg';
|
| 25 |
+
const output = await classifier(url);
|
| 26 |
+
console.log(output);
|
| 27 |
+
// [
|
| 28 |
+
// { label: 'tabby, tabby cat', score: 0.5210835337638855 },
|
| 29 |
+
// { label: 'Egyptian cat', score: 0.313551127910614 },
|
| 30 |
+
// { label: 'tiger cat', score: 0.14324277639389038 },
|
| 31 |
+
// { label: 'lynx, catamount', score: 0.005053747445344925 },
|
| 32 |
+
// { label: 'remote control, remote', score: 0.001643550000153482 }
|
| 33 |
+
// ]
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
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`).
|