Xenova HF staff commited on
Commit
c70d1dd
1 Parent(s): 413ce83

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -0
README.md CHANGED
@@ -6,4 +6,42 @@ pipeline_tag: depth-estimation
6
 
7
  https://huggingface.co/depth-anything/Depth-Anything-V2-Small with ONNX weights to be compatible with Transformers.js.
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  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`).
 
6
 
7
  https://huggingface.co/depth-anything/Depth-Anything-V2-Small with ONNX weights to be compatible with Transformers.js.
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/@xenova/transformers) using:
12
+ ```bash
13
+ npm i @xenova/transformers
14
+ ```
15
+
16
+ **Example:** Depth estimation w/ `onnx-community/depth-anything-v2-small`.
17
+ ```js
18
+ import { pipeline } from '@xenova/transformers';
19
+
20
+ // Create depth estimation pipeline
21
+ const depth_estimator = await pipeline('depth-estimation', 'onnx-community/depth-anything-v2-small');
22
+
23
+ // Predict depth of an image
24
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg';
25
+ const { predicted_depth, depth } = await depth_estimator(url);
26
+ depth.save('depth.png');
27
+ // {
28
+ // predicted_depth: Tensor {
29
+ // dims: [ 518, 686 ],
30
+ // type: 'float32',
31
+ // data: Float32Array(147456) [ ... ],
32
+ // size: 355348
33
+ // },
34
+ // depth: RawImage {
35
+ // data: Uint8Array(307200) [ ... ],
36
+ // width: 640,
37
+ // height: 480,
38
+ // channels: 1
39
+ // }
40
+ // }
41
+ ```
42
+
43
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/vfxg_YtHfvna4gZBOCRgD.png)
44
+
45
+ ---
46
+
47
  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`).