Views
No views yet
npm i @xenova/transformersXenova/depth-anything-small-hf.1import { pipeline } from '@xenova/transformers';
2
3// Create depth-estimation pipeline
4const depth_estimator = await pipeline('depth-estimation', 'Xenova/depth-anything-small-hf');
5
6// Predict depth map for the given image
7const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/bread_small.png';
8const output = await depth_estimator(url);
9// {
10// predicted_depth: Tensor {
11// dims: [350, 518],
12// type: 'float32',
13// data: Float32Array(181300) [...],
14// size: 181300
15// },
16// depth: RawImage {
17// data: Uint8Array(271360) [...],
18// width: 640,
19// height: 424,
20// channels: 1
21// }
22// }output.depth.save('depth.png');
onnx).