-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathrun_dlclive_benchmark.py
More file actions
57 lines (45 loc) · 1.8 KB
/
run_dlclive_benchmark.py
File metadata and controls
57 lines (45 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
DeepLabCut Toolbox (deeplabcut.org)
© A. & M. Mathis Labs
Licensed under GNU Lesser General Public License v3.0
"""
# Script for running the official benchmark from Kane et al, 2020.
# Please share your results at https://github.com/DeepLabCut/DLC-inferencespeed-benchmark
import glob
import os
import pathlib
from dlclive import benchmark_videos, download_benchmarking_data
from dlclive.engine import Engine
datafolder = os.path.join(pathlib.Path(__file__).parent.absolute(), "Data-DLC-live-benchmark")
if not os.path.isdir(datafolder): # only download if data doesn't exist!
# Downloading data.... this takes a while (see terminal)
download_benchmarking_data(datafolder)
n_frames = 10000 # change to 10000 for testing on a GPU!
pixels = [2500, 10000, 40000, 160000, 320000, 640000]
dog_models = glob.glob(datafolder + "/dog/*[!avi]")
dog_video = glob.glob(datafolder + "/dog/*.avi")[0]
mouse_models = glob.glob(datafolder + "/mouse_lick/*[!avi]")
mouse_video = glob.glob(datafolder + "/mouse_lick/*.avi")[0]
this_dir = os.path.dirname(os.path.realpath(__file__))
# storing results in /benchmarking/results: (for your PR)
out_dir = os.path.normpath(this_dir + "/results")
if not os.path.isdir(out_dir):
os.mkdir(out_dir)
for model_path in dog_models:
benchmark_videos(
model_path=model_path,
model_type="base" if Engine.from_model_path(model_path) == Engine.TENSORFLOW else "pytorch",
video_path=dog_video,
output=out_dir,
n_frames=n_frames,
pixels=pixels,
)
for model_path in mouse_models:
benchmark_videos(
model_path=model_path,
model_type="base" if Engine.from_model_path(model_path) == Engine.TENSORFLOW else "pytorch",
video_path=mouse_video,
output=out_dir,
n_frames=n_frames,
pixels=pixels,
)