Skip to content

Commit 595c295

Browse files
authored
[WIP] Integration with DeepLabCut 3.0 - PyTorch Engine (#121)
1 parent 091dd3d commit 595c295

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+11774
-3837
lines changed

.github/workflows/testing.yml

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches: [main]
66
pull_request:
7-
branches: [main]
87

98
jobs:
109
build:
@@ -13,33 +12,36 @@ jobs:
1312
strategy:
1413
fail-fast: false
1514
matrix:
16-
os: [ubuntu-latest, macos-latest] #windows-latest
17-
python-version: ["3.9", "3.10"] #3.11+ issues with TF
18-
exclude:
19-
- os: macos-latest
20-
python-version: "3.9"
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
python-version: ["3.10", "3.11", "3.12"]
2117
include:
2218
- os: ubuntu-latest
2319
path: ~/.cache/pip
2420
- os: macos-latest
2521
path: ~/Library/Caches/pip
22+
- os: windows-latest
23+
path: ~\AppData\Local\pip\Cache
24+
exclude:
25+
- os: windows-latest
26+
python-version: "3.11"
27+
- os: windows-latest
28+
python-version: "3.12"
2629

2730
steps:
2831
- name: Checkout code
2932
uses: actions/checkout@v4
3033

31-
- name: Set up Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@v4
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v6
3336
with:
37+
enable-cache: true
38+
version: "0.9.5"
3439
python-version: ${{ matrix.python-version }}
3540

36-
- name: Set up Python
37-
uses: conda-incubator/setup-miniconda@v3
38-
with:
39-
channels: conda-forge,defaults
40-
channel-priority: strict
41-
python-version: ${{ matrix.python-version }}
42-
41+
- name: Install the project
42+
run: uv sync --all-extras --dev
43+
shell: bash
44+
4345
- name: Install ffmpeg
4446
run: |
4547
if [ "$RUNNER_OS" == "Linux" ]; then
@@ -51,27 +53,9 @@ jobs:
5153
choco install ffmpeg
5254
fi
5355
shell: bash
54-
55-
- name: Install PyTables through Conda
56-
shell: bash -el {0} # Important: activates the conda environment
57-
run: |
58-
conda install pytables==3.8.0 "numpy<2"
59-
60-
- name: Install dependencies via Conda
61-
shell: bash -el {0}
62-
run: conda install -y "numpy>=1.26,<2.0"
63-
64-
- name: Install Poetry
65-
run: pip install --upgrade pip wheel poetry
66-
67-
- name: Regenerate Poetry lock
68-
run: poetry lock --no-cache
69-
70-
- name: Install project dependencies
71-
run: poetry install --with dev
7256

7357
- name: Run DLC Live Tests
74-
run: poetry run dlc-live-test --nodisplay
58+
run: uv run dlc-live-test --nodisplay
7559

7660
- name: Run Functional Benchmark Test
77-
run: poetry run pytest tests/test_benchmark_script.py
61+
run: uv run pytest

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
# Data related to benchmark!
44
benchmarking/Data*
55
benchmarking/results*
6-
6+
dlclive/check_install/dlc-live-tmp*
77
*test*
88
**DS_Store*
99
*vscode*
1010

1111
**/__MACOSX/
1212

13+
# Include tests directory (negate the *test* pattern for tests/)
14+
!tests/
15+
!tests/**
16+
1317
# Byte-compiled / optimized / DLL files
1418
__pycache__/
1519
*.py[cod]
@@ -18,6 +22,10 @@ __pycache__/
1822
# C extensions
1923
*.so
2024

25+
# uv or poetry lock files
26+
poetry.lock
27+
uv.lock
28+
2129
# Distribution / packaging
2230
.Python
2331
build/

README.md

Lines changed: 208 additions & 76 deletions
Large diffs are not rendered by default.

benchmarking/run_dlclive_benchmark.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import glob
1313

1414
from dlclive import benchmark_videos, download_benchmarking_data
15+
from dlclive.engine import Engine
1516

1617
datafolder = os.path.join(
1718
pathlib.Path(__file__).parent.absolute(), "Data-DLC-live-benchmark"
@@ -36,8 +37,22 @@
3637
if not os.path.isdir(out_dir):
3738
os.mkdir(out_dir)
3839

39-
for m in dog_models:
40-
benchmark_videos(m, dog_video, output=out_dir, n_frames=n_frames, pixels=pixels)
41-
42-
for m in mouse_models:
43-
benchmark_videos(m, mouse_video, output=out_dir, n_frames=n_frames, pixels=pixels)
40+
for model_path in dog_models:
41+
benchmark_videos(
42+
model_path=model_path,
43+
model_type="base" if Engine.from_model_path(model_path) == Engine.TENSORFLOW else "pytorch",
44+
video_path=dog_video,
45+
output=out_dir,
46+
n_frames=n_frames,
47+
pixels=pixels
48+
)
49+
50+
for model_path in mouse_models:
51+
benchmark_videos(
52+
model_path=model_path,
53+
model_type="base" if Engine.from_model_path(model_path) == Engine.TENSORFLOW else "pytorch",
54+
video_path=mouse_video,
55+
output=out_dir,
56+
n_frames=n_frames,
57+
pixels=pixels
58+
)

dlclive/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
Licensed under GNU Lesser General Public License v3.0
66
"""
77

8-
from dlclive.version import __version__, VERSION
8+
# Check which backends are installed and get available backends
9+
# (Emits a warning if neither TensorFlow nor PyTorch is installed)
10+
from dlclive.utils import get_available_backends
11+
_AVAILABLE_BACKENDS = get_available_backends()
12+
13+
from dlclive.display import Display
914
from dlclive.dlclive import DLCLive
10-
from dlclive.processor import Processor
11-
from dlclive.benchmark import benchmark, benchmark_videos, download_benchmarking_data
15+
from dlclive.processor.processor import Processor
16+
from dlclive.version import VERSION, __version__
17+
from dlclive.benchmark import benchmark_videos, download_benchmarking_data

0 commit comments

Comments
 (0)