Update README.md
Browse files
README.md
CHANGED
@@ -25,19 +25,30 @@ pip install -e .
|
|
25 |
## Usage
|
26 |
|
27 |
```python
|
28 |
-
|
29 |
-
from
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
prompt_depth_path = "assets/example_images/arkit_depth.png"
|
34 |
-
image = load_image(image_path).to(DEVICE)
|
35 |
-
prompt_depth = load_depth(prompt_depth_path).to(DEVICE) # 192x256, ARKit LiDAR depth in meters
|
36 |
|
37 |
-
model = PromptDA.from_pretrained("depth-anything/prompt-depth-anything-vitl").to(DEVICE).eval()
|
38 |
-
depth = model.predict(image, prompt_depth) # HxW, depth in meters
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
```
|
42 |
|
43 |
## Citation
|
|
|
25 |
## Usage
|
26 |
|
27 |
```python
|
28 |
+
import requests
|
29 |
+
from PIL import Image
|
30 |
+
from transformers import PromptDepthAnythingForDepthEstimation, PromptDepthAnythingImageProcessor
|
31 |
|
32 |
+
url = "https://github.com/DepthAnything/PromptDA/blob/main/assets/example_images/image.jpg?raw=true"
|
33 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
|
|
|
|
|
|
34 |
|
|
|
|
|
35 |
|
36 |
+
image_processor = PromptDepthAnythingImageProcessor.from_pretrained("depth-anything/prompt-depth-anything-vitl-hf")
|
37 |
+
model = PromptDepthAnythingForDepthEstimation.from_pretrained("depth-anything/prompt-depth-anything-vitl-hf")
|
38 |
+
|
39 |
+
prompt_depth_url = "https://github.com/DepthAnything/PromptDA/blob/main/assets/example_images/arkit_depth.png?raw=true"
|
40 |
+
prompt_depth = Image.open(requests.get(prompt_depth_url, stream=True).raw)
|
41 |
+
|
42 |
+
inputs = image_processor(images=image, return_tensors="pt", prompt_depth=prompt_depth)
|
43 |
+
with torch.no_grad():
|
44 |
+
outputs = model(**inputs)
|
45 |
+
post_processed_output = image_processor.post_process_depth_estimation(
|
46 |
+
outputs,
|
47 |
+
target_sizes=[(image.height, image.width)],
|
48 |
+
)
|
49 |
+
|
50 |
+
predicted_depth = post_processed_output[0]["predicted_depth"]
|
51 |
+
|
52 |
```
|
53 |
|
54 |
## Citation
|