66"""
77
88
9- import os
109import sys
1110import shutil
1211import warnings
1514import urllib .request
1615import argparse
1716from pathlib import Path
18- import tarfile
17+ from dlclibrary .dlcmodelzoo .modelzoo_download import (
18+ download_huggingface_model ,
19+ )
1920
2021
2122def urllib_pbar (count , blockSize , totalSize ):
@@ -25,6 +26,7 @@ def urllib_pbar(count, blockSize, totalSize):
2526 sys .stdout .write ("\b " * len (outstr ))
2627 sys .stdout .flush ()
2728
29+
2830def main (display :bool = None ):
2931 parser = argparse .ArgumentParser (
3032 description = "Test DLC-Live installation by downloading and evaluating a demo DLC project!" )
@@ -43,31 +45,23 @@ def main(display:bool=None):
4345 tmp_dir .mkdir (mode = 0o775 ,exist_ok = True )
4446
4547 video_file = str (tmp_dir / 'dog_clip.avi' )
46- model_tarball = tmp_dir / 'DLC_Dog_resnet_50_iteration-0_shuffle-0.tar.gz'
47- model_dir = model_tarball .with_suffix ('' ).with_suffix ('' ) # remove two suffixes (tar.gz)
48-
48+ model_dir = tmp_dir / 'DLC_Dog_resnet_50_iteration-0_shuffle-0'
4949
5050 # download dog test video from github:
5151 print (f"Downloading Video to { video_file } " )
5252 url_link = "https://github.com/DeepLabCut/DeepLabCut-live/blob/master/check_install/dog_clip.avi?raw=True"
5353 urllib .request .urlretrieve (url_link , video_file , reporthook = urllib_pbar )
5454
5555 # download exported dog model from DeepLabCut Model Zoo
56- if Path (model_tarball ).exists ():
57- print ('Tarball already downloaded, using cached version' )
56+ if Path (model_dir / 'snapshot-75000.pb' ).exists ():
57+ print ('Model already downloaded, using cached version' )
5858 else :
5959 print ("Downloading full_dog model from the DeepLabCut Model Zoo..." )
60- model_url = "http://deeplabcut.rowland.harvard.edu/models/DLC_Dog_resnet_50_iteration-0_shuffle-0.tar.gz"
61- urllib .request .urlretrieve (model_url , str (model_tarball ), reporthook = urllib_pbar )
62-
63- print ('Untarring compressed model' )
64- model_file = tarfile .open (str (model_tarball ))
65- model_file .extractall (str (model_dir .parent ))
66- model_file .close ()
60+ download_huggingface_model ("full_dog" , model_dir )
6761
6862 # assert these things exist so we can give informative error messages
6963 assert Path (video_file ).exists ()
70- assert Path (model_dir ). exists () and Path ( model_dir ). is_dir ()
64+ assert Path (model_dir / 'snapshot-75000.pb' ). exists ()
7165
7266 # run benchmark videos
7367 print ("\n Running inference...\n " )
0 commit comments