This is a single-file tinygrad
implementation of Depth-Anything-V2. Check out the interactive Demo!
To install the required dependencies, use the requirements.txt
file:
pip install -r requirements.txt
Please refer to Hugging Face for the required model weights. After downloading the .safetensors
files, place them under the weights/
directory. The filenames should follow this pattern:
weights/vits.safetensors
weights/vitb.safetensors
weights/vitl.safetensors
Model | Download Link |
---|---|
Small | Download |
Base | Download |
Large | Download |
usage: main.py [-h] [--vit-size {s,b,l,g}] --input INPUT
[--output OUTPUT]
Run DPTv2 model on an input image.
options:
-h, --help Show this help message and exit.
--vit-size {s,b,l,g} Specify the Vision Transformer size (`s`, `b`, `l`, `g`).
--input INPUT Path to the input image.
--output OUTPUT Path to save the output image.
-
To display the output image using
matplotlib
:python main.py --vit-size s --input docs/input.jpg
-
To save the output to a file:
python main.py --vit-size l --input docs/input.jpg --output docs/output.jpg
This README was partially written with the assistance of AI.