Skip to content

Commit

Permalink
type hints for benchmark (and also some missing ones in dlclive)
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat committed Feb 14, 2024
1 parent 427c126 commit 5a14d97
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
66 changes: 33 additions & 33 deletions dlclive/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys
import warnings
import subprocess
import typing
from typing import List, Optional, Tuple, Union
import pickle
import colorcet as cc
from PIL import ImageColor
Expand Down Expand Up @@ -148,22 +148,22 @@ def get_system_info() -> dict:


def benchmark(
model_path,
video_path,
tf_config=None,
resize=None,
pixels=None,
cropping=None,
dynamic=(False, 0.5, 10),
n_frames=1000,
print_rate=False,
display=False,
pcutoff=0.0,
display_radius=3,
cmap="bmy",
save_poses=False,
save_video=False,
output=None,
model_path: str,
video_path: str,
tf_config: Optional[tf.ConfigProto] = None,
resize: Optional[float] = None,
pixels: Optional[int] = None,
cropping: Optional[List[int]] = None,
dynamic: Tuple[bool, float, int] = (False, 0.5, 10),
n_frames: int = 1000,
print_rate: bool = False,
display: bool = False,
pcutoff: float = 0.0,
display_radius: int = 3,
cmap: str = "bmy",
save_poses: bool = False,
save_video: bool = False,
output: Optional[str] = None,
) -> typing.Tuple[np.ndarray, tuple, bool, dict]:
""" Analyze DeepLabCut-live exported model on a video:
Calculate inference time,
Expand Down Expand Up @@ -516,22 +516,22 @@ def save_inf_times(


def benchmark_videos(
model_path,
video_path,
output=None,
n_frames=1000,
tf_config=None,
resize=None,
pixels=None,
cropping=None,
dynamic=(False, 0.5, 10),
print_rate=False,
display=False,
pcutoff=0.5,
display_radius=3,
cmap="bmy",
save_poses=False,
save_video=False,
model_path: str,
video_path: Union[str, List[str]],
output: Optional[str] = None,
n_frames: int = 1000,
tf_config: Optional[tf.ConfigProto] = None,
resize: Optional[Union[float, List[float]]] = None,
pixels: Optional[Union[int, List[int]]] = None,
cropping: Optional[List[int]] = None,
dynamic: Tuple[bool, float, int] = (False, 0.5, 10),
print_rate: bool = False,
display: bool = False,
pcutoff: float = 0.5,
display_radius: int = 3,
cmap: str = "bmy",
save_poses: bool = False,
save_video: bool = False,
):
"""Analyze videos using DeepLabCut-live exported models.
Analyze multiple videos and/or multiple options for the size of the video
Expand Down
6 changes: 3 additions & 3 deletions dlclive/dlclive.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def parameterization(self) -> dict:
"""
return {param: getattr(self, param) for param in self.PARAMETERS}

def process_frame(self, frame):
def process_frame(self, frame: np.ndarray) -> np.ndarray:
"""
Crops an image according to the object's cropping and dynamic properties.
Expand Down Expand Up @@ -237,7 +237,7 @@ def process_frame(self, frame):

return frame

def init_inference(self, frame=None, **kwargs):
def init_inference(self, frame=None, **kwargs) -> np.ndarray:
"""
Load model and perform inference on first frame -- the first inference is usually very slow.
Expand Down Expand Up @@ -376,7 +376,7 @@ def init_inference(self, frame=None, **kwargs):

return pose

def get_pose(self, frame=None, **kwargs):
def get_pose(self, frame=None, **kwargs) -> np.ndarray:
"""
Get the pose of an image
Expand Down

0 comments on commit 5a14d97

Please sign in to comment.