Skip to content

Commit fe0e6da

Browse files
authored
Merge pull request #2613 from DeepLabCut/pytorch_dlc
🔥 New main backend Deep Learning Library (Engine) for DeepLabCut: PyTorch. Voilà.
2 parents 02155ed + ad5c0c4 commit fe0e6da

397 files changed

Lines changed: 55473 additions & 5887 deletions

File tree

Some content is hidden

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

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
build-and-test:
88
working_directory: ~/circleci-demo-python-django
99
docker:
10-
- image: circleci/python:3.8 # primary container for the build job
10+
- image: circleci/python:3.10 # primary container for the build job
1111
auth:
1212
username: mydockerhub-user
1313
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference

.github/workflows/publish-book.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v4
1313

14-
- name: Set up Python 3.9
14+
- name: Set up Python 3.10
1515
uses: actions/setup-python@v4
1616
with:
17-
python-version: 3.9
17+
python-version: 3.10
1818

1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
22-
python -m pip install .[tf,docs]
22+
python -m pip install .[docs]
2323
pip install jupyter-book sphinxcontrib-mermaid
2424
2525
- name: Build the book

.github/workflows/python-package.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ jobs:
6464
pip install git+https://github.com/${{ github.repository }}.git@${{ github.sha }}
6565
python examples/testscript.py
6666
python examples/testscript_multianimal.py
67+
python examples/testscript_pytorch_single_animal.py
68+
python examples/testscript_pytorch_multi_animal.py

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ _build/*
1010
/examples/3D*
1111
/examples/m3*
1212
/examples/OUT
13+
/examples/pretrained*
1314
.local
1415
.DS_Store
1516
examples/.DS_Store
@@ -18,6 +19,15 @@ examples/.DS_Store
1819
*.ckpt
1920
snapshot-*
2021

22+
# Modelzoo checkpoints
23+
deeplabcut/modelzoo/checkpoints/
24+
25+
# PyTorch backbone weights
26+
deeplabcut/pose_estimation_pytorch/models/backbones/pretrained_weights/
27+
28+
# Wandb files
29+
wandb/
30+
2131
# Byte-compiled / optimized / DLL files
2232
__pycache__/
2333
*.py[cod]
@@ -115,7 +125,10 @@ ENV/
115125
# Spyder project settings
116126
.spyderproject
117127
.spyproject
128+
129+
# IDEs configurations
118130
.vscode/*
131+
.idea/*
119132

120133
# Rope project settings
121134
.ropeproject

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-yaml
7+
- id: end-of-file-fixer
8+
- id: name-tests-test
9+
- id: trailing-whitespace
10+
- repo: https://github.com/PyCQA/isort
11+
rev: 5.12.0
12+
hooks:
13+
- id: isort
14+
- repo: https://github.com/psf/black
15+
rev: 22.3.0
16+
hooks:
17+
- id: black
18+
language_version: python3

NOTICE.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
https://github.com/DeepLabCut/DeepLabCut
66
77
Please see AUTHORS for contributors.
8-
https://github.com/DeepLabCut/DeepLabCut/blob/master/AUTHORS
8+
https://github.com/DeepLabCut/DeepLabCut/blob/main/AUTHORS
99
1010
Licensed under GNU Lesser General Public License v3.0
1111
include:
@@ -17,6 +17,7 @@
1717

1818
# License for files adapted from DeeperCut by Eldar Insafutdinov
1919
# https://github.com/eldar/pose-tensorflow
20+
2021
# Applies to most files in deeplabcut.pose_estimation_tensorflow
2122
- header: |
2223
DeepLabCut Toolbox (deeplabcut.org)
@@ -107,3 +108,8 @@
107108
include:
108109
- deeplabcut/pose_tracking_pytorch/solver/scheduler_factory.py
109110
- deeplabcut/pose_tracking_pytorch/model/backones/vit_pytorch.py
111+
112+
# PyTorch license
113+
114+
- header: |
115+
See https://github.com/pytorch/pytorch/blob/main/LICENSE

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,24 @@
6060

6161
Please click the link above for all the information you need to get started! Please note that currently we support only Python 3.10+ (see conda files for guidance).
6262

63-
Developers Stable Release:
64-
- Very quick start: You need to have TensorFlow installed (up to v2.10 supported across platforms) `pip install "deeplabcut[gui,tf]"` that includes all functions plus GUIs, or `pip install deeplabcut[tf]` (headless version with PyTorch and TensorFlow).
65-
66-
Developers Alpha Release:
67-
- We also have an alpha release of PyTorch DeepLabCut available! [Please see here for instructions and information](https://github.com/DeepLabCut/DeepLabCut/blob/pytorch_docs/docs/pytorch/user_guide.md).
63+
Developers Stable Release: very quick start (Python 3.10+ required) to install
64+
DeepLabCut with the PyTorch engine
65+
66+
- [Install PyTorch](https://pytorch.org/get-started/locally/) (**select the desired
67+
CUDA version if you want to use a GPU**): `pip install torch torchvision`
68+
- Then, [install `pytables`](https://www.pytables.org/usersguide/installation.html): `conda install -c conda-forge pytables==3.8.0`
69+
- Finally, install `DeepLabCut` (with all functions + the GUI):
70+
`pip install --pre "deeplabcut[gui]"` or `pip install --pre "deeplabcut"` (headless
71+
version with PyTorch)!
72+
73+
To use the TensorFlow engine (requires Python 3.10; TF up to v2.10 supported on Windows,
74+
up to v2.12 on other platforms): you'll need to run `pip install "deeplabcut[gui,tf]"`
75+
(which includes all functions plus GUIs) or `pip install "deeplabcut[tf]"` (headless
76+
version with PyTorch and TensorFlow).
6877

6978
We recommend using our conda file, see [here](https://github.com/DeepLabCut/DeepLabCut/blob/main/conda-environments/README.md) or the new [`deeplabcut-docker` package](https://github.com/DeepLabCut/DeepLabCut/tree/main/docker).
7079

71-
# [Documentation: The DeepLabCut Process](https://deeplabcut.github.io/DeepLabCut)
80+
# [Documentation: The DeepLabCut Process](https://deeplabcut.github.io/DeepLabCut/README.html)
7281

7382
Our docs walk you through using DeepLabCut, and key API points. For an overview of the toolbox and workflow for project management, see our step-by-step at [Nature Protocols paper](https://doi.org/10.1038/s41596-019-0176-0).
7483

@@ -82,9 +91,7 @@ For a deeper understanding and more resources for you to get started with Python
8291

8392
🐭 pose tracking of single animals demo [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DeepLabCut/DeepLabCut/blob/master/examples/COLAB/COLAB_DEMO_mouse_openfield.ipynb)
8493

85-
🐭🐭🐭 pose tracking of multiple animals demo [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DeepLabCut/DeepLabCut/blob/master/examples/COLAB/COLAB_3miceDemo.ipynb)
86-
87-
- See [more demos here](https://github.com/DeepLabCut/DeepLabCut/blob/main/examples/README.md). We provide data and several Jupyter Notebooks: one that walks you through a demo dataset to test your installation, and another Notebook to run DeepLabCut from the beginning on your own data. We also show you how to use the code in Docker, and on Google Colab.
94+
See [more demos here](https://github.com/DeepLabCut/DeepLabCut/blob/main/examples/README.md). We provide data and several Jupyter Notebooks: one that walks you through a demo dataset to test your installation, and another Notebook to run DeepLabCut from the beginning on your own data. We also show you how to use the code in Docker, and on Google Colab.
8895

8996
# Why use DeepLabCut?
9097

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ only_build_toc_files: true
55

66
sphinx:
77
config:
8-
autodoc_mock_imports: ["wx"]
8+
autodoc_mock_imports: ["wx", "matplotlib", "qtpy", "PySide6", "napari", "shiboken6"]
99
mermaid_output_format: raw
1010
extra_extensions:
1111
- numpydoc

_toc.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ parts:
4646
chapters:
4747
- file: docs/ModelZoo
4848
- file: docs/recipes/UsingModelZooPupil
49-
- file: docs/recipes/MegaDetectorDLCLive
5049
- caption: 🧑‍🍳 Cookbook (detailed helper guides)
5150
chapters:
52-
- file: docs/tutorial
5351
- file: docs/convert_maDLC
5452
- file: docs/recipes/OtherData
5553
- file: docs/recipes/io

conda-environments/DEEPLABCUT.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
#Licensed under GNU Lesser General Public License v3.0
1010
#
1111
# DeepLabCut environment
12-
# FIRST: INSTALL CORRECT DRIVER for GPU, see https://stackoverflow.com/questions/30820513/what-is-the-correct-version-of-cuda-for-my-nvidia-driver/30820690
1312
#
14-
# AFTER THIS FILE IS INSTALLED, if you have a GPU be sure to install cudnn from conda-forge: conda install cudnn -c conda-forge
13+
# FIRST: If you have an NVIDIA GPU and want to use it, check that you have drivers installed!
14+
# To check if your GPUs are visible to PyTorch (and thus DeepLabCut), run:
15+
# >>> python -c "import torch; print(torch.cuda.is_available())"
16+
#
17+
# If "False" is printed, PyTorch (and thus DeepLabCut) cannot access your GPU. For
18+
# more information, see: https://pytorch.org/get-started/locally/
1519
#
1620
# install: conda env create -f DEEPLABCUT.yaml
1721
# update: conda env update -f DEEPLABCUT.yaml
@@ -29,4 +33,6 @@ dependencies:
2933
- ffmpeg
3034
- pytables==3.8.0
3135
- pip:
36+
- torch
37+
- torchvision
3238
- "git+https://github.com/DeepLabCut/DeepLabCut.git@pytorch_dlc#egg=deeplabcut[gui,modelzoo,wandb]"

0 commit comments

Comments
 (0)