19
19
)
20
20
21
21
22
+ MODEL_NAME = "superanimal_quadruped"
23
+ SNAPSHOT_NAME = "snapshot-700000.pb"
24
+
25
+
22
26
def urllib_pbar (count , blockSize , totalSize ):
23
27
percent = int (count * blockSize * 100 / totalSize )
24
28
outstr = f"{ round (percent )} %"
@@ -27,19 +31,18 @@ def urllib_pbar(count, blockSize, totalSize):
27
31
sys .stdout .flush ()
28
32
29
33
30
- def main (display : bool = None ):
34
+ def main ():
31
35
parser = argparse .ArgumentParser (
32
36
description = "Test DLC-Live installation by downloading and evaluating a demo DLC project!" )
33
37
parser .add_argument ('--nodisplay' , action = 'store_false' , help = "Run the test without displaying tracking" )
34
38
args = parser .parse_args ()
35
-
36
- if display is None :
37
- display = args .nodisplay
39
+ display = args .nodisplay
38
40
39
41
if not display :
40
42
print ('Running without displaying video' )
41
43
42
44
# make temporary directory in $HOME
45
+ # TODO: why create this temp directory in $HOME?
43
46
print ("\n Creating temporary directory...\n " )
44
47
tmp_dir = Path ().home () / 'dlc-live-tmp'
45
48
tmp_dir .mkdir (mode = 0o775 ,exist_ok = True )
@@ -48,25 +51,24 @@ def main(display:bool=None):
48
51
model_dir = tmp_dir / 'DLC_Dog_resnet_50_iteration-0_shuffle-0'
49
52
50
53
# download dog test video from github:
54
+ # TODO: Should check if the video's already there before downloading it (should have been cloned with the files)
51
55
print (f"Downloading Video to { video_file } " )
52
56
url_link = "https://github.com/DeepLabCut/DeepLabCut-live/blob/master/check_install/dog_clip.avi?raw=True"
53
57
urllib .request .urlretrieve (url_link , video_file , reporthook = urllib_pbar )
54
58
55
- # download exported dog model from DeepLabCut Model Zoo
56
- if Path (model_dir / 'snapshot-75000.pb' ).exists ():
59
+ # download model from the DeepLabCut Model Zoo
60
+ if Path (model_dir / SNAPSHOT_NAME ).exists ():
57
61
print ('Model already downloaded, using cached version' )
58
62
else :
59
63
print ("Downloading full_dog model from the DeepLabCut Model Zoo..." )
60
- download_huggingface_model ("full_dog" , model_dir )
64
+ download_huggingface_model (MODEL_NAME , model_dir )
61
65
62
66
# assert these things exist so we can give informative error messages
63
- assert Path (video_file ).exists ()
64
- assert Path (model_dir / 'snapshot-75000.pb' ).exists ()
67
+ assert Path (video_file ).exists (), f"Missing video file { video_file } "
68
+ assert Path (model_dir / SNAPSHOT_NAME ).exists (), f"Missing model file { model_dir / SNAPSHOT_NAME } "
65
69
66
70
# run benchmark videos
67
71
print ("\n Running inference...\n " )
68
- # model_dir = "DLC_Dog_resnet_50_iteration-0_shuffle-0"
69
- # print(video_file)
70
72
benchmark_videos (str (model_dir ), video_file , display = display , resize = 0.5 , pcutoff = 0.25 )
71
73
72
74
# deleting temporary files
@@ -80,9 +82,4 @@ def main(display:bool=None):
80
82
81
83
82
84
if __name__ == "__main__" :
83
-
84
-
85
- display = args .nodisplay
86
-
87
-
88
- main (display = args .nodisplay )
85
+ main ()
0 commit comments