Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: type hints for benchmark #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading