Xenova HF staff commited on
Commit
c3ce400
1 Parent(s): e5476ff

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -0
README.md CHANGED
@@ -6,4 +6,30 @@ pipeline_tag: depth-estimation
6
 
7
  https://huggingface.co/depth-anything/Depth-Anything-V2-Large 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-Large 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-large`.
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-large');
22
+
23
+ // Predict depth of an image
24
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg';
25
+ const { depth } = await depth_estimator(url);
26
+
27
+ // Visualize the output
28
+ depth.save('depth.png');
29
+ ```
30
+
31
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/qsFAeXvMgph3Dm15nTICU.png)
32
+
33
+ ---
34
+
35
  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`).