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

fix #111: Use floats for resize #116

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
# You can use PyPy versions in python-version. For example, pypy2 and pypy3
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"] #3.9 only failing for tables on macos and windows; mwm 6302021
python-version: ["3.8", "3.9", "3.10"] #3.9 only failing for tables on macos and windows; mwm 6302021
include:
- os: ubuntu-latest
path: ~/.cache/pip
Expand Down Expand Up @@ -42,6 +42,6 @@ jobs:
shell: bash
- name: Install and test
run: |
python -m pip install --upgrade pip wheel poetry
python -m poetry install
python -m poetry run dlc-live-test --nodisplay
python -m pip install --upgrade pip
python -m pip install .
dlc-live-test --nodisplay
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ DeepLabCut-live offers some analysis tools that allow users to peform the follow
1. Test inference speed across a range of image sizes, downsizing images by specifying the `resize` or `pixels` parameter. Using the `pixels` parameter will resize images to the desired number of `pixels`, without changing the aspect ratio. Results will be saved (along with system info) to a pickle file if you specify an output directory.
##### python
```python
dlclive.benchmark_videos('/path/to/exported/model', ['/path/to/video1', '/path/to/video2'], output='/path/to/output', resize=[1.0, 0.75, '0.5'])
dlclive.benchmark_videos('/path/to/exported/model', ['/path/to/video1', '/path/to/video2'], output='/path/to/output', resize=[1.0, 0.75, 0.5])
```
##### command line
```
Expand Down
18 changes: 9 additions & 9 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 @@ -151,8 +151,8 @@ def benchmark(
model_path,
video_path,
tf_config=None,
resize=None,
pixels=None,
resize: Optional[float] = None,
pixels: Optional[int] = None,
cropping=None,
dynamic=(False, 0.5, 10),
n_frames=1000,
Expand All @@ -164,7 +164,7 @@ def benchmark(
save_poses=False,
save_video=False,
output=None,
) -> typing.Tuple[np.ndarray, tuple, bool, dict]:
) -> Tuple[np.ndarray, tuple, bool, dict]:
""" Analyze DeepLabCut-live exported model on a video:
Calculate inference time,
display keypoints, or
Expand Down Expand Up @@ -521,8 +521,8 @@ def benchmark_videos(
output=None,
n_frames=1000,
tf_config=None,
resize=None,
pixels=None,
resize: Optional[Union[float, List[float]]] = None,
pixels: Optional[Union[int, List[int]]] = None,
cropping=None,
dynamic=(False, 0.5, 10),
print_rate=False,
Expand Down Expand Up @@ -551,7 +551,7 @@ def benchmark_videos(
path to directory to save results
tf_config : :class:`tensorflow.ConfigProto`
tensorflow session configuration
resize : int, optional
resize : float, optional
resize factor. Can only use one of resize or pixels. If both are provided, will use pixels. by default None
pixels : int, optional
downsize image to this number of pixels, maintaining aspect ratio. Can only use one of resize or pixels. If both are provided, will use pixels. by default None
Expand Down Expand Up @@ -603,10 +603,10 @@ def benchmark_videos(
# fix resize

if pixels:
pixels = pixels if type(pixels) is list else [pixels]
pixels = [int(p) for p in pixels] if type(pixels) is list else [int(pixels)]
resize = [None for p in pixels]
elif resize:
resize = resize if type(resize) is list else [resize]
resize = [float(r) for r in resize] if type(resize) is list else [float(resize)]
pixels = [None for r in resize]
else:
resize = [None]
Expand Down
Loading
Loading