Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Done
  • Loading branch information
isaacrobinson2000 committed Jan 15, 2024
2 parents fb44c10 + 9b657de commit ab19010
Show file tree
Hide file tree
Showing 19 changed files with 186 additions and 94 deletions.
36 changes: 14 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,7 @@ DIPLOMAT also includes a UI for performing tracking and several other tools for

## Installation

To install DIPLOMAT with PIP right now, you can and install it with pip using one of the following commands below:
```bash
# For working with SLEAP projects:
pip install diplomat-track[sleap]
# For working with DeepLabCut projects:
pip install diplomat-track[dlc]
```
To install DIPLOMAT with GUI elements and supervised tracking support, use one of the commands below:
```bash
# For using DIPLOMAT with SLEAP
pip install diplomat-track[sleap, gui]
# Again, replace sleap with dlc to install with DeepLabCut support.
pip install diplomat-track[dlc, gui]
```

**NOTE:** DIPLOMAT also includes two environment configuration files for setting up DIPLOMAT with
DIPLOMAT also includes four environment configuration files for setting up DIPLOMAT with
[mamba](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html), which can
be installed on Windows, Linux, or MacOS using the [Miniforge](https://github.com/conda-forge/miniforge) installer.
To create an environment using mamba, run one of these four commands:
Expand All @@ -60,7 +45,8 @@ mamba activate DIPLOMAT-DEEPLABCUT
mamba activate DIPLOMAT-SLEAP
```

For a more thorough explanation of the installation process, see the [documentation](https://diplomat.readthedocs.io/en/latest/installation.html).
For a more thorough explanation of the installation process and alternative installation methods, see the
[documentation](https://diplomat.readthedocs.io/en/latest/installation.html).

## Usage

Expand All @@ -69,27 +55,33 @@ For a more thorough explanation of the installation process, see the [documentat
To run DIPLOMAT on a video once it is installed, simply use DIPLOMAT's `unsupervised` and `supervised` commands to track a video:
```bash
# Run DIPLOMAT with no UI...
diplomat unsupervised -c path/to/config -v path/to/video
diplomat track -c path/to/config -v path/to/video
# Run DIPLOMAT with UI...
diplomat supervised -c path/to/config -v path/to/video
diplomat track_and_interact -c path/to/config -v path/to/video
```

Multiple videos can be tracked by passing them as a list:
```bash
diplomat unsupervised -c path/to/config -v [path/to/video1, path/to/video2, "path/to/video3"]
diplomat track -c path/to/config -v [path/to/video1, path/to/video2, "path/to/video3"]
```

Once tracking is done, DIPLOMAT can create labeled videos via it's `annotate` subcommand:
```bash
diplomat annotate -c path/to/config -v path/to/video
```

If you need to reopen the UI to make further major modifications, you can do so using the interact subcommand:
```bash
diplomat interact -s path/to/ui_state.dipui
```
This displays the full UI again for making further edits. Results are saved back to the same files.

If you need to make minor modifications after tracking a video, you can do so using the tweak subcommand:
```bash
diplomat tweak -c path/to/config -v path/to/video
```
This will display a stripped down version of the supervised editing UI, allowing for minor tweaks to be made to the tracks, and then
saved back to the same file.
This will display a stripped down version of the interactive editing UI, allowing for minor tweaks to be made to the
tracks, and then saved back to the same file.

For a list of additional ways DIPLOMAT can be used, see the [documentation](https://diplomat.readthedocs.io/en/latest/basic_usage.html).

Expand Down
2 changes: 1 addition & 1 deletion conda-environments/DIPLOMAT-DEEPLABCUT-CPU.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ dependencies:
- tensorflow
- keras
- pip:
- deeplabcut
- deeplabcut==2.3.8
- diplomat-track
2 changes: 1 addition & 1 deletion conda-environments/DIPLOMAT-DEEPLABCUT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ dependencies:
- tensorflow-gpu
- keras
- pip:
- deeplabcut
- deeplabcut==2.3.8
- diplomat-track
2 changes: 1 addition & 1 deletion conda-environments/DIPLOMAT-SLEAP-CPU.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ dependencies:
- conda-forge::cudnn=8.2.1
- nvidia::cuda-nvcc=11.3
- pip:
- sleap
- sleap==1.3.3
- diplomat-track
2 changes: 1 addition & 1 deletion conda-environments/DIPLOMAT-SLEAP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ dependencies:
- conda-forge::cudnn=8.2.1
- nvidia::cuda-nvcc=11.3
- pip:
- sleap
- sleap==1.3.3
- diplomat-track
8 changes: 4 additions & 4 deletions diplomat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from diplomat.predictor_ops import list_predictor_plugins, get_predictor_settings, test_predictor_plugin
from diplomat.frontend_ops import list_all_frontends, list_loaded_frontends
from diplomat.utils.video_splitter import split_videos
from diplomat.core_ops import track, supervised, unsupervised, annotate, tweak, yaml, convert, restore
from diplomat.core_ops import track_with, track, track_and_interact, annotate, tweak, yaml, convert, interact

__all__ = [
"list_predictor_plugins",
Expand All @@ -18,14 +18,14 @@
"list_all_frontends",
"list_loaded_frontends",
"split_videos",
"track_with",
"track_and_interact",
"track",
"supervised",
"unsupervised",
"annotate",
"tweak",
"yaml",
"convert",
"restore"
"interact"
]


Expand Down
6 changes: 3 additions & 3 deletions diplomat/_cli_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ def get_static_cli_tree() -> dict:
"test": diplomat.test_predictor_plugin,
"list_settings": diplomat.get_predictor_settings
},
"track_with": diplomat.track_with,
"track_and_interact": diplomat.track_and_interact,
"track": diplomat.track,
"supervised": diplomat.supervised,
"unsupervised": diplomat.unsupervised,
"annotate": diplomat.annotate,
"split_videos": diplomat.split_videos,
"tweak": diplomat.tweak,
"yaml": diplomat.yaml,
"convert": diplomat.convert,
"restore": diplomat.restore,
"interact": diplomat.interact,
"frontends": {
"__description": "Contains subcommands for listing available frontends and inspecting the functions "
"each frontend supports.",
Expand Down
55 changes: 31 additions & 24 deletions diplomat/core_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def yaml(

@allow_arbitrary_flags
@typecaster_function
def track(
def track_with(
config: Union[List[PathLike], PathLike],
videos: Optional[Union[List[PathLike], PathLike]] = None,
frame_stores: Optional[Union[List[PathLike], PathLike]] = None,
Expand All @@ -178,6 +178,7 @@ def track(
):
"""
Run DIPLOMAT tracking on videos and/or frame stores. Automatically select a frontend based on the passed arguments.
Allows for selecting a specific tracker, or predictor.
:param config: The path to the configuration file for the project. The format of this argument will depend on the frontend.
:param videos: A single path or list of paths to video files to run analysis on.
Expand Down Expand Up @@ -243,7 +244,7 @@ def track(

@allow_arbitrary_flags
@typecaster_function
def unsupervised(
def track(
config: Union[List[PathLike], PathLike],
videos: Optional[Union[List[PathLike], PathLike]] = None,
frame_stores: Optional[Union[List[PathLike], PathLike]] = None,
Expand All @@ -253,24 +254,28 @@ def unsupervised(
**extra_args
):
"""
Run diplomat in unsupervised mode on the specified config and videos or frame stores. An alias for
DIPLOMAT track with the SegmentedFramePassEngine predictor.
Run diplomat in a non-interactive tracking mode on the specified config and videos or frame stores. An alias for
DIPLOMAT track_with with the SegmentedFramePassEngine predictor. The interactive UI can be restored later using
diplomat interact function or cli command.
:param config: The path to the configuration file for the project. The format of this argument will depend on the frontend.
:param config: The path to the configuration file for the project. The format of this argument will depend on the
frontend.
:param videos: A single path or list of paths to video files to run analysis on.
:param frame_stores: A single path or list of paths to frame store files to run analysis on.
:param num_outputs: An integer, the number of bodies to track in the video. Defaults to 1.
:param settings: An optional dictionary, listing the settings to use for the SegmentedFramePassEngine predictor plugin.
If not specified, the frontend will determine the settings in a frontend specific manner. To see the settings the
SegmentedFramePassEngine supports, use the "diplomat predictors list_settings -p SegmentedFramePassEngine" command
or "diplomat.get_predictor_settings('SegmentedFramePassEngine')". To get more information about how a frontend gets
settings if not passed, set the help_extra parameter to True to print additional settings for the selected
frontend instead of running tracking.
:param help_extra: Boolean, if set to true print extra settings for the automatically selected frontend instead of running tracking.
:param extra_args: Any additional arguments (if the CLI, flags starting with '--') are passed to the automatically selected frontend.
To see valid values, run track with extra_help flag set to true.
:param settings: An optional dictionary, listing the settings to use for the SegmentedFramePassEngine predictor
plugin. If not specified, the frontend will determine the settings in a frontend specific manner.
To see the settings the SegmentedFramePassEngine supports, use the
"diplomat predictors list_settings -p SegmentedFramePassEngine" command
or "diplomat.get_predictor_settings('SegmentedFramePassEngine')". To get more information about
how a frontend gets settings if not passed, set the help_extra parameter to True to print
additional settings for the selected frontend instead of running tracking.
:param help_extra: Boolean, if set to true print extra settings for the automatically selected frontend instead of
running tracking.
:param extra_args: Any additional arguments (if the CLI, flags starting with '--') are passed to the automatically
selected frontend. To see valid values, run track with extra_help flag set to true.
"""
track(
track_with(
config=config,
videos=videos,
frame_stores=frame_stores,
Expand All @@ -284,7 +289,7 @@ def unsupervised(

@allow_arbitrary_flags
@typecaster_function
def supervised(
def track_and_interact(
config: Union[List[PathLike], PathLike],
videos: Optional[Union[List[PathLike], PathLike]] = None,
frame_stores: Optional[Union[List[PathLike], PathLike]] = None,
Expand All @@ -294,8 +299,8 @@ def supervised(
**extra_args
):
"""
Run diplomat in supervised mode on the specified config and videos or frame stores. An alias for
DIPLOMAT track with the SupervisedSegmentedFramePassEngine predictor.
Run diplomat in interactive tracking mode on the specified config and videos or frame stores. An alias for
DIPLOMAT track_with with the SupervisedSegmentedFramePassEngine predictor.
:param config: The path to the configuration file for the project. The format of this argument will depend on the frontend.
:param videos: A single path or list of paths to video files to run analysis on.
Expand All @@ -311,7 +316,7 @@ def supervised(
:param extra_args: Any additional arguments (if the CLI, flags starting with '--') are passed to the automatically selected frontend.
To see valid values, run track with extra_help flag set to true.
"""
track(
track_with(
config=config,
videos=videos,
frame_stores=frame_stores,
Expand Down Expand Up @@ -375,8 +380,9 @@ def tweak(
**extra_args
):
"""
Make modifications to DIPLOMAT produced tracking results created for a video using a limited version supervised
labeling UI. Allows for touching up and fixing any minor issues that may arise after tracking and saving results.
Make modifications to DIPLOMAT produced tracking results created for a video using a limited version of the
interactive labeling UI. Allows for touching up and fixing any minor issues that may arise after tracking and
saving results.
:param config: The path to the configuration file for the project. The format of this argument will depend on the
frontend.
Expand Down Expand Up @@ -464,12 +470,13 @@ def convert(


@typecaster_function
def restore(
def interact(
state: Union[List[PathLike], PathLike]
):
"""
Restore the state of the diplomat UI from a .dipui file. Allows for reloading the UI when diplomat crashes.
Settings and backend will be restored automatically based on the settings and info passed during the first run.
Open diplomat's interactive UI from a .dipui file. Allows for reloading the UI when diplomat crashes, or for
further editing. Settings and backend will be restored automatically based on the settings and info passed during
the first run.
:param state: A path or list of paths to the ui states to restore. Files should be of ".dipui" format.
"""
Expand Down
2 changes: 1 addition & 1 deletion diplomat/frontends/csv/tweak_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def tweak_videos(
**kwargs
):
"""
Make minor modifications and tweaks to arbitrary csv files using DIPLOMAT's supervised UI.
Make minor modifications and tweaks to arbitrary csv files using DIPLOMAT's light interactive UI.
:param config: The path (or list of paths) to the csv file(s) to edit.
:param videos: Paths to video file(s) corresponding to the provided csv files.
Expand Down
3 changes: 2 additions & 1 deletion diplomat/frontends/deeplabcut/tweak_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def tweak_videos(
video_type: str = "",
):
"""
Make minor modifications and tweaks to tracked results produced by DEEPLABCUT (or DIPLOMAT) using the supervised UI.
Make minor modifications and tweaks to tracked results produced by DEEPLABCUT (or DIPLOMAT) using the interactive
UI.
:param config: The path to the config.yaml file for the project.
:param videos: A single video or list of videos to tweak, passed in order to modify.
Expand Down
2 changes: 1 addition & 1 deletion diplomat/frontends/sleap/tweak_results_sleap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def tweak_videos(
**kwargs
):
"""
Make minor modifications and tweaks to sleap results (stored in .slp files) using DIPLOMAT's supervised UI.
Make minor modifications and tweaks to sleap results (stored in .slp files) using DIPLOMAT's interactive UI.
:param config: The path (or list of paths) to the sleap model(s) used for inference, each as either as a folder or zip file.
:param videos: Paths to the sleap label files, or .slp files, to make minor modifications to, NOT the video files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def frames(self, frames):

class SupervisedSegmentedFramePassEngine(SegmentedFramePassEngine):
"""
The supervised version of the :plugin:`~diplomat.predictors.SegmentedFramePassEngine` predictor.
The supervised (aka interactive) version of the :plugin:`~diplomat.predictors.SegmentedFramePassEngine` predictor.
Provides a GUI for modifying results at the end of the tracking process.
"""

Expand Down
4 changes: 2 additions & 2 deletions diplomat/utils/tweak_ui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Contains utilities for loading user tracks into a lighter version of the supervised UI to allow for minor modifications
Contains utilities for loading user tracks into a lighter version of the interactive UI to allow for minor modifications
to user saved tracking data.
"""

Expand Down Expand Up @@ -246,7 +246,7 @@ def tweak(
make_app: bool = True
):
"""
Load a lighter version of the supervised UI to allow for minor modifications to user saved tracking data.
Load a lighter version of the interactive UI to allow for minor modifications to user saved tracking data.
:param parent: The parent wx widget of the UI. Can be None, indicating no parent widget, or an independent window.
:param video_path: The path to the video to display in the editor.
Expand Down
2 changes: 1 addition & 1 deletion diplomat/wx_gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
controls for video playback, pose editing, plotting, etc. Used by the
:plugin:`~diplomat.predictors.SupervisedSegmentedFramePassEngine` predictor,
:plugin:`~diplomat.predictors.SupervisedFramePassEngine` predictor,
:cli:`diplomat tweak` command, :cli:`diplomat supervised` command, and :cli:`diplomat restore` command.
:cli:`diplomat tweak` command, :cli:`diplomat track_and_interact` command, and :cli:`diplomat interact` command.
"""
2 changes: 1 addition & 1 deletion diplomat/wx_gui/fpe_editor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Includes DIPLOMAT's main GUI editor window. Displayed when a supervised run is performed or restored.
Includes DIPLOMAT's main GUI editor window. Displayed when an interactive run is performed or restored.
The GUI allows for editing and rerunning tracking on the fly by the user.
"""

Expand Down
Loading

0 comments on commit ab19010

Please sign in to comment.