DPT (Dense Prediction Transformer) model trained on 1.4 million images for monocular depth estimation. It was introduced in the paper
Vision Transformers for Dense Prediction
by Ranftl et al. (2021) and first released in
this repository
.
Disclaimer: The team releasing DPT did not write a model card for this model so this model card has been written by the Hugging Face team.
Model description
This DPT model uses the
BEiT
model as backbone and adds a neck + head on top for monocular depth estimation.
How to use
Here is how to use this model for zero-shot depth estimation on an image:
from transformers import DPTImageProcessor, DPTForDepthEstimation
import torch
import numpy as np
from PIL import Image
import requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
processor = DPTImageProcessor.from_pretrained("Intel/dpt-beit-base-384")
model = DPTForDepthEstimation.from_pretrained("Intel/dpt-beit-base-384")
# prepare image for the model
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predicted_depth = outputs.predicted_depth
# interpolate to original size
prediction = torch.nn.functional.interpolate(
predicted_depth.unsqueeze(1),
size=image.size[::-1],
mode="bicubic",
align_corners=False,
)
# visualize the prediction
output = prediction.squeeze().cpu().numpy()
formatted = (output * 255 / np.max(output)).astype("uint8")
depth = Image.fromarray(formatted)
or one can use the pipeline API:
from transformers import pipeline
pipe = pipeline(task="depth-estimation", model="Intel/dpt-beit-base-384")
result = pipe("http://images.cocodataset.org/val2017/000000039769.jpg")
result["depth"]
Runs of Intel dpt-beit-base-384 on huggingface.co
326
Total runs
0
24-hour runs
-6
3-day runs
-35
7-day runs
-3.4K
30-day runs
More Information About dpt-beit-base-384 huggingface.co Model
dpt-beit-base-384 huggingface.co is an AI model on huggingface.co that provides dpt-beit-base-384's model effect (), which can be used instantly with this Intel dpt-beit-base-384 model. huggingface.co supports a free trial of the dpt-beit-base-384 model, and also provides paid use of the dpt-beit-base-384. Support call dpt-beit-base-384 model through api, including Node.js, Python, http.
dpt-beit-base-384 huggingface.co is an online trial and call api platform, which integrates dpt-beit-base-384's modeling effects, including api services, and provides a free online trial of dpt-beit-base-384, you can try dpt-beit-base-384 online for free by clicking the link below.
Intel dpt-beit-base-384 online free url in huggingface.co:
dpt-beit-base-384 is an open source model from GitHub that offers a free installation service, and any user can find dpt-beit-base-384 on GitHub to install. At the same time, huggingface.co provides the effect of dpt-beit-base-384 install, users can directly use dpt-beit-base-384 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.