YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Depth Recognition
Author: goldenboy
Monocular depth estimation on football broadcast screenshots using Depth Anything V2 (DAv2) via Hugging Face Transformers.
Features
- Loads DAv2 models from a local
models/directory (no Hugging Face cache at inference time) - Supports three model sizes: small, base, large
- Downloads football broadcast video clips and extracts screenshots automatically
- Runs depth inference on all images in
images/and saves results tooutput/
Project Structure
depth_recognition/
βββ main.py
βββ requirements.txt
βββ README.md
βββ models/
β βββ Depth-Anything-V2-Small-hf/
β βββ Depth-Anything-V2-Base-hf/
β βββ Depth-Anything-V2-Large-hf/
βββ videos/
β βββ broadcast_corner_kick.mp4
β βββ broadcast_goal.mp4
βββ images/
β βββ broadcast_corner_kick_0060.jpg
β βββ broadcast_corner_kick_0150.jpg
β βββ ...
βββ output/
βββ broadcast_corner_kick_0060_small_depth.png
βββ ...
Setup
- Create a virtual environment (recommended):
python -m venv .venv
.venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Download a DAv2 model into the local
models/folder:
python main.py --download-model small
Optional larger models (better quality, slower, more disk space):
python main.py --download-model base
python main.py --download-model large
| Model size | Params | Local folder |
|---|---|---|
small |
~25M | models/Depth-Anything-V2-Small-hf/ |
base |
~98M | models/Depth-Anything-V2-Base-hf/ |
large |
~335M | models/Depth-Anything-V2-Large-hf/ |
Usage
Full pipeline (download videos, extract screenshots, run inference)
python main.py
Choose model size
python main.py --model-size small
python main.py --model-size base
python main.py --model-size large
Extract screenshots only
python main.py --extract-screenshots
Re-extract even if screenshots already exist:
python main.py --extract-screenshots --force-extract
Run on a single image
python main.py --image images/broadcast_corner_kick_0060.jpg --model-size small
Download broadcast videos only
python main.py --download-videos
Input Images
Screenshots are extracted from professional football broadcast clips in the infactory-ai/soccer-events dataset:
- Corner kick clip β 4 frames
- Goal clip β 3 frames
You can also add your own .jpg / .png images to images/ and run inference on them.
Output
Depth maps are saved as grayscale PNG files in output/:
{image_name}_{model_size}_depth.png
Example: broadcast_corner_kick_0060_small_depth.png
Model Sources
Notes
- GPU is used automatically when available; CPU inference also works.
- Base and Large models are under CC-BY-NC-4.0. Small is Apache-2.0.
- First model download requires an internet connection. Inference uses only local files.
Author
goldenboy
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support