Skip to content

Commit 7593c87

Browse files
committed
Merge branch 'MMathisLab-data' into maxim/dlclive3
2 parents 7599121 + ef37746 commit 7593c87

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ benchmarking/results*
88
**DS_Store*
99
*vscode*
1010

11+
**/__MACOSX/
12+
1113
# Byte-compiled / optimized / DLL files
1214
__pycache__/
1315
*.py[cod]

dlclive/benchmark.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,47 @@
2727
except ModuleNotFoundError as err:
2828
has_pandas = False
2929

30-
try:
30+
from dlclive import DLCLive
31+
from dlclive import VERSION
32+
from dlclive import __file__ as dlcfile
33+
34+
from dlclive.utils import decode_fourcc
35+
36+
37+
def download_benchmarking_data(
38+
target_dir=".",
39+
url="https://huggingface.co/datasets/mwmathis/DLCspeed_benchmarking/resolve/main/Data-DLC-live-benchmark.zip",
40+
):
41+
"""
42+
Downloads and extracts DeepLabCut-Live benchmarking data (videos & DLC models).
43+
"""
44+
import os
45+
import urllib.request
3146
from tqdm import tqdm
47+
import zipfile
3248

33-
has_tqdm = True
34-
except ModuleNotFoundError as err:
35-
has_tqdm = False
49+
# Avoid nested folder issue
50+
if os.path.basename(os.path.normpath(target_dir)) == "Data-DLC-live-benchmark":
51+
target_dir = os.path.dirname(os.path.normpath(target_dir))
52+
os.makedirs(target_dir, exist_ok=True) # Ensure target directory exists
3653

54+
zip_path = os.path.join(target_dir, "Data-DLC-live-benchmark.zip")
3755

38-
from dlclive import DLCLive
39-
from dlclive.utils import decode_fourcc
40-
from dlclive.version import VERSION
56+
if os.path.exists(zip_path):
57+
print(f"{zip_path} already exists. Skipping download.")
58+
else:
59+
def show_progress(count, block_size, total_size):
60+
pbar.update(block_size)
61+
62+
print(f"Downloading the benchmarking data from {url} ...")
63+
pbar = tqdm(unit="B", total=0, position=0, desc="Downloading")
64+
65+
filename, _ = urllib.request.urlretrieve(url, filename=zip_path, reporthook=show_progress)
66+
pbar.close()
4167

68+
print(f"Extracting {zip_path} to {target_dir} ...")
69+
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
70+
zip_ref.extractall(target_dir)
4271

4372
def get_system_info() -> dict:
4473
"""

0 commit comments

Comments
 (0)