|
27 | 27 | except ModuleNotFoundError as err:
|
28 | 28 | has_pandas = False
|
29 | 29 |
|
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 |
31 | 46 | from tqdm import tqdm
|
| 47 | + import zipfile |
32 | 48 |
|
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 |
36 | 53 |
|
| 54 | + zip_path = os.path.join(target_dir, "Data-DLC-live-benchmark.zip") |
37 | 55 |
|
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() |
41 | 67 |
|
| 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) |
42 | 71 |
|
43 | 72 | def get_system_info() -> dict:
|
44 | 73 | """
|
|
0 commit comments