xingyang1 keetrap commited on
Commit
19549fd
·
verified ·
1 Parent(s): 84774c4

Update README.md (#1)

Browse files

- Update README.md (04a4bb526ab265606320941d566916df84b32b1f)


Co-authored-by: Parteek <keetrap@users.noreply.huggingface.co>

Files changed (1) hide show
  1. README.md +79 -3
README.md CHANGED
@@ -1,7 +1,83 @@
1
  ---
2
- license: mit
3
  library_name: transformers
 
4
  pipeline_tag: depth-estimation
5
- widget:
6
- - inference: false
 
 
7
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
2
  library_name: transformers
3
+ license: mit
4
  pipeline_tag: depth-estimation
5
+ arxiv: <2502.19204>
6
+ tags:
7
+ - distill-any-depth
8
+ - vision
9
  ---
10
+ # Distill Any Depth Small - Transformers Version
11
+
12
+ ## Introduction
13
+ We present Distill-Any-Depth, a new SOTA monocular depth estimation model trained with our proposed knowledge distillation algorithms. It was introduced in the paper [Distill Any Depth: Distillation Creates a Stronger Monocular Depth Estimator](http://arxiv.org/abs/2502.19204).
14
+
15
+ This model checkpoint is compatible with the transformers library.
16
+
17
+ [Online demo](https://huggingface.co/spaces/xingyang1/Distill-Any-Depth).
18
+
19
+ ### How to use
20
+
21
+ Here is how to use this model to perform zero-shot depth estimation:
22
+
23
+ ```python
24
+ from transformers import pipeline
25
+ from PIL import Image
26
+ import requests
27
+ # load pipe
28
+ pipe = pipeline(task="depth-estimation", model="xingyang1/Distill-Any-Depth-Small-hf")
29
+ # load image
30
+ url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
31
+ image = Image.open(requests.get(url, stream=True).raw)
32
+ # inference
33
+ depth = pipe(image)["depth"]
34
+ ```
35
+
36
+ Alternatively, you can use the model and processor classes:
37
+
38
+ ```python
39
+ from transformers import AutoImageProcessor, AutoModelForDepthEstimation
40
+ import torch
41
+ import numpy as np
42
+ from PIL import Image
43
+ import requests
44
+
45
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
46
+ image = Image.open(requests.get(url, stream=True).raw)
47
+
48
+ image_processor = AutoImageProcessor.from_pretrained("xingyang1/Distill-Any-Depth-Small-hf")
49
+ model = AutoModelForDepthEstimation.from_pretrained("xingyang1/Distill-Any-Depth-Small-hf")
50
+
51
+ # prepare image for the model
52
+ inputs = image_processor(images=image, return_tensors="pt")
53
+
54
+ with torch.no_grad():
55
+ outputs = model(**inputs)
56
+
57
+ # interpolate to original size and visualize the prediction
58
+ post_processed_output = image_processor.post_process_depth_estimation(
59
+ outputs,
60
+ target_sizes=[(image.height, image.width)],
61
+ )
62
+
63
+ predicted_depth = post_processed_output[0]["predicted_depth"]
64
+ depth = (predicted_depth - predicted_depth.min()) / (predicted_depth.max() - predicted_depth.min())
65
+ depth = depth.detach().cpu().numpy() * 255
66
+ depth = Image.fromarray(depth.astype("uint8"))
67
+ )
68
+ ```
69
+
70
+
71
+ If you find this project useful, please consider citing:
72
+
73
+ ```bibtex
74
+ @article{he2025distill,
75
+ title = {Distill Any Depth: Distillation Creates a Stronger Monocular Depth Estimator},
76
+ author = {Xiankang He and Dongyan Guo and Hongji Li and Ruibo Li and Ying Cui and Chi Zhang},
77
+ year = {2025},
78
+ journal = {arXiv preprint arXiv: 2502.19204}
79
+ }
80
+ ```
81
+
82
+ ## Model Card Author
83
+ [Parteek Kamboj](https://huggingface.co/keetrap)