2222from dlclive .version import VERSION
2323
2424
25- def get_system_info () -> dict :
26- """
27- Returns a summary of system information relevant to running benchmarking.
28-
29- Returns
30- -------
31- dict
32- A dictionary containing the following system information:
33- - host_name (str): Name of the machine.
34- - op_sys (str): Operating system.
35- - python (str): Path to the Python executable, indicating the conda/virtual environment in use.
36- - device_type (str): Type of device used ('GPU' or 'CPU').
37- - device (list): List containing the name of the GPU or CPU brand.
38- - freeze (list): List of installed Python packages with their versions.
39- - python_version (str): Version of Python in use.
40- - git_hash (str or None): If installed from git repository, hash of HEAD commit.
41- - dlclive_version (str): Version of the DLCLive package.
42- """
43-
44- # Get OS and host name
45- op_sys = platform .platform ()
46- host_name = platform .node ().replace (" " , "" )
47-
48- # Get Python executable path
49- if platform .system () == "Windows" :
50- host_python = sys .executable .split (os .path .sep )[- 2 ]
51- else :
52- host_python = sys .executable .split (os .path .sep )[- 3 ]
53-
54- # Try to get git hash if possible
55- git_hash = None
56- dlc_basedir = os .path .dirname (os .path .dirname (__file__ ))
57- try :
58- git_hash = (
59- subprocess .check_output (["git" , "rev-parse" , "HEAD" ], cwd = dlc_basedir )
60- .decode ("utf-8" )
61- .strip ()
62- )
63- except subprocess .CalledProcessError :
64- # Not installed from git repo, e.g., pypi
65- pass
66-
67- # Get device info (GPU or CPU)
68- if torch .cuda .is_available ():
69- dev_type = "GPU"
70- dev = [torch .cuda .get_device_name (torch .cuda .current_device ())]
71- else :
72- from cpuinfo import get_cpu_info
73-
74- dev_type = "CPU"
75- dev = [get_cpu_info ()["brand_raw" ]]
76-
77- return {
78- "host_name" : host_name ,
79- "op_sys" : op_sys ,
80- "python" : host_python ,
81- "device_type" : dev_type ,
82- "device" : dev ,
83- "freeze" : list (freeze .freeze ()),
84- "python_version" : sys .version ,
85- "git_hash" : git_hash ,
86- "dlclive_version" : VERSION ,
87- }
88-
89-
9025def benchmark (
9126 video_path : str ,
9227 model_path : str ,
@@ -106,7 +41,6 @@ def benchmark(
10641 save_poses = False ,
10742 draw_keypoint_names = False ,
10843 cmap = "bmy" ,
109- get_sys_info = True ,
11044 save_video = False ,
11145):
11246 """
@@ -152,8 +86,6 @@ def benchmark(
15286 Whether to display keypoint names on video frames in the saved video.
15387 cmap : str, optional, default='bmy'
15488 Colormap from the colorcet library for keypoint visualization.
155- get_sys_info : bool, optional, default=True
156- Whether to print system information.
15789 save_video : bool, optional, default=False
15890 Whether to save the labeled video.
15991
@@ -268,9 +200,6 @@ def benchmark(
268200 if save_video :
269201 vwriter .release ()
270202
271- if get_sys_info :
272- print (get_system_info ())
273-
274203 if save_poses :
275204 individuals = dlc_live .read_config ()["metadata" ].get ("individuals" , [])
276205 n_individuals = len (individuals ) or 1
0 commit comments