DepthAnything / Depth-Anything-V2

[NeurIPS 2024] Depth Anything V2. A More Capable Foundation Model for Monocular Depth Estimation
https://depth-anything-v2.github.io
Apache License 2.0
3.99k stars 345 forks source link

Output Image Completely Black Using 'depth-anything/Depth-Anything-V2-Metric-Indoor-Large-hf' Model #148

Closed jamesbaker1 closed 3 months ago

jamesbaker1 commented 3 months ago

Hey everyone,

First of all, I love your work!

Issue Description

I am trying to get the metric depth estimation model working from the Huggingface example, but I am getting a completely black image as my output.

Code Example

from transformers import pipeline
from PIL import Image
import requests

# load pipe
pipe = pipeline(task="depth-estimation", model="depth-anything/Depth-Anything-V2-Metric-Indoor-Large-hf")

# load image
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)

# inference
depth = pipe(image)["depth"]

Error:

/usr/local/lib/python3.10/dist-packages/transformers/pipelines/depth_estimation.py:106: RuntimeWarning: invalid value encountered in divide
  formatted = (output * 255 / np.max(output)).astype("uint8")

Output: download

jamesbaker1 commented 3 months ago

I figured it out - transformers needs to be >=4.45.0 but pip does not yet have that wheel

!pip install git+https://github.com/huggingface/transformers