Skip to content

Commit 3f27779

Browse files
gkane26MMathisLabAlexEMG
authored
Updates to benchmarking (#29)
* remove old bench.py * Add dynamic cropping to benchmark (#28) * add dynamic cropping to benchmark * add cropping to benchmark * dlclive: make sure dynamic cropping indices are integers * Update README.md * dowloading data, streamlined process * typo fixed Co-authored-by: Mackenzie Mathis <[email protected]> Co-authored-by: alex <[email protected]>
1 parent bae2cac commit 3f27779

File tree

10 files changed

+161
-488
lines changed

10 files changed

+161
-488
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# DeepLabCut-live
22

3+
# Data related to benchmark!
4+
benchmarking/Data*
5+
benchmarking/results*
6+
37
*test*
48
**DS_Store*
59
*vscode*

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DeepLabCut-live SDK<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/1572296495650-Y4ZTJ2XP2Z9XF1AD74VW/ke17ZwdGBToddI8pDm48kMulEJPOrz9Y8HeI7oJuXxR7gQa3H78H3Y0txjaiv_0fDoOvxcdMmMKkDsyUqMSsMWxHk725yiiHCCLfrh8O1z5QPOohDIaIeljMHgDF5CVlOqpeNLcJ80NK65_fV7S1UZiU3J6AN9rgO1lHw9nGbkYQrCLTag1XBHRgOrY8YAdXW07ycm2Trb21kYhaLJjddA/DLC_logo_blk-01.png?format=1000w" width="350" title="DLC-live" alt="DLC LIVE!" align="right" vspace = "50">
1+
# DeepLabCut-live! SDK<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/1606082050387-M8M1CFI5DFUZCBAAUI0W/ke17ZwdGBToddI8pDm48kLuMKy7Ws6mFofiFehYynfdZw-zPPgdn4jUwVcJE1ZvWQUxwkmyExglNqGp0IvTJZUJFbgE-7XRK3dMEBRBhUpzp2tFVMcEgqZM8QO7VXXQogrsLnYKC4n4YnYuHC1HMRWygQlqMNAoTF9HaycikLeg/DLClive.png?format=750w" width="350" title="DLC-live" alt="DLC LIVE!" align="right" vspace = "50">
22

33
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
44
![PyPI - Python Version](https://img.shields.io/pypi/v/deeplabcut-live)
@@ -40,6 +40,8 @@ Note, you can then test your installation by running:
4040

4141
If installed properly, this script will i) create a temporary folder ii) download the full_dog model from the [DeepLabCut Model Zoo](http://www.mousemotorlab.org/dlc-modelzoo), iii) download a short video clip of a dog, and iv) run inference while displaying keypoints. v) remove the temporary folder.
4242

43+
<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/1606081086014-TG9GWH63ZGGOO7K779G3/ke17ZwdGBToddI8pDm48kHiSoSToKfKUI9t99vKErWoUqsxRUqqbr1mOJYKfIPR7LoDQ9mXPOjoJoqy81S2I8N_N4V1vUb5AoIIIbLZhVYxCRW4BPu10St3TBAUQYVKcOoIGycwr1shdgJWzLuxyzjLbSRGBFFxjYMBr42yCvRK5HHsLZWtMlAHzDU294nCd/dlclivetest.png?format=1000w" width="650" title="DLC-live-test" alt="DLC LIVE TEST" align="center" vspace = "50">
44+
4345
### Quick Start: instructions for use:
4446

4547
1. Initialize `Processor` (if desired)
@@ -76,7 +78,7 @@ dlc_live.get_pose(<your image>)
7678
- `<your image>` = is a numpy array of each frame
7779

7880

79-
### Benchmarking/Analyzing Exported DeepLabCut Models
81+
### Benchmarking/Analyzing your exported DeepLabCut models
8082

8183
DeepLabCut-live offers some analysis tools that allow users to peform the following operations on videos, from python or from the command line:
8284

benchmarking/run.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
import glob
1212

13-
from dlclive import benchmark_model_by_size
13+
from dlclive import benchmark_videos
1414

1515
# Update the datafolder to where the data is:
1616
datafolder = "/your/path/to/data/here"
@@ -27,21 +27,15 @@
2727
# storing results in /benchmarking/results: (for your PR)
2828
out_dir = os.path.normpath(this_dir + "/results")
2929

30+
if not os.path.isdir(out_dir):
31+
os.path.mkdir(out_dir)
32+
3033
for ind_m, m in enumerate(dog_models):
3134
print("\n\nMODEL {:d} / 8".format(ind_m))
32-
benchmark_model_by_size(
33-
m, dog_video, ind_m, out_dir=out_dir, n_frames=n_frames, pixels=pixels
34-
)
35+
benchmark_videos(m, dog_video, output=out_dir, n_frames=n_frames, pixels=pixels)
3536

3637
offset = ind_m + 1
3738

3839
for ind_m, m in enumerate(mouse_models):
3940
print("\n\nMODEL {:d} / 8".format(ind_m))
40-
benchmark_model_by_size(
41-
m,
42-
mouse_video,
43-
ind_m + offset,
44-
out_dir=out_dir,
45-
n_frames=n_frames,
46-
pixels=pixels,
47-
)
41+
benchmark_videos(m, mouse_video, output=out_dir, n_frames=n_frames, pixels=pixels)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
DeepLabCut Toolbox (deeplabcut.org)
3+
© A. & M. Mathis Labs
4+
5+
Licensed under GNU Lesser General Public License v3.0
6+
"""
7+
8+
# Script for running the official benchmark from Kane et al, 2020.
9+
# Please share your results at https://github.com/DeepLabCut/DLC-inferencespeed-benchmark
10+
11+
import os, pathlib
12+
import glob
13+
14+
from dlclive import benchmark_videos, download_benchmarking_data
15+
16+
datafolder = os.path.join(
17+
pathlib.Path(__file__).parent.absolute(), "Data-DLC-live-benchmark"
18+
)
19+
20+
if not os.path.isdir(datafolder): # only download if data doesn't exist!
21+
# Downloading data.... this takes a while (see terminal)
22+
download_benchmarking_data(datafolder)
23+
24+
n_frames = 10000 # change to 10000 for testing on a GPU!
25+
pixels = [2500, 10000, 40000, 160000, 320000, 640000]
26+
27+
dog_models = glob.glob(datafolder + "/dog/*[!avi]")
28+
dog_video = glob.glob(datafolder + "/dog/*.avi")[0]
29+
mouse_models = glob.glob(datafolder + "/mouse_lick/*[!avi]")
30+
mouse_video = glob.glob(datafolder + "/mouse_lick/*.avi")[0]
31+
32+
this_dir = os.path.dirname(os.path.realpath(__file__))
33+
# storing results in /benchmarking/results: (for your PR)
34+
out_dir = os.path.normpath(this_dir + "/results")
35+
36+
if not os.path.isdir(out_dir):
37+
os.mkdir(out_dir)
38+
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)

dlclive/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
from dlclive.version import __version__, VERSION
99
from dlclive.dlclive import DLCLive
1010
from dlclive.processor import Processor
11-
from dlclive.bench import benchmark_model_by_size
12-
from dlclive.benchmark import benchmark, benchmark_videos
11+
from dlclive.benchmark import benchmark, benchmark_videos, download_benchmarking_data

0 commit comments

Comments
 (0)