Single-animal at a glance#
This page summarizes the main DeepLabCut functions used in a standard single-animal 2D pose-estimation workflow, from project creation to analyzed videos.
Start Python#
Open a terminal and start an interactive Python session, for example with IPython:
ipython
Then import DeepLabCut:
import deeplabcut
Workflow#
1. Create a project#
project_name = "project_name"
experimenter = "experimenter"
video_paths = [
"/absolute/path/to/video_1.mp4",
"/absolute/path/to/video_2.mp4",
]
config_path = deeplabcut.create_new_project(
project_name,
experimenter,
video_paths,
copy_videos=True,
)
Note
Use absolute paths to your video files. The returned config_path is the full path to
the project config.yaml file and is used throughout the rest of the workflow.
2. Configure the project#
Open the generated config.yaml file and edit it for your experiment.
At this stage, define the body parts or points of interest that you want to track. You can also adjust project settings such as the number of frames to extract, visualization settings, and training options.
Important
Do not include spaces in body-part names.
3. Extract frames#
deeplabcut.extract_frames(config_path)
4. Label frames#
deeplabcut.label_frames(config_path)
5. Check labels#
deeplabcut.check_labels(config_path)
Tip
This step is optional, but strongly recommended. Use the generated labeled images to visually confirm that the annotations were saved correctly before training.
6. Create the training dataset#
deeplabcut.create_training_dataset(config_path)
7. Train the network#
deeplabcut.train_network(config_path)
8. Evaluate the trained network#
deeplabcut.evaluate_network(config_path)
Inspect the evaluation results before moving on to video analysis. If pose-estimation quality is not sufficient, improve the labels, add more training data, or train for longer before continuing.
9. Analyze videos#
deeplabcut.analyze_videos(
config_path,
video_paths,
)
10. Filter predictions#
deeplabcut.filterpredictions(
config_path,
video_paths,
)
Note
Filtering is optional. It can help smooth pose predictions before plotting trajectories or creating labeled videos.
11. Plot trajectories#
deeplabcut.plot_trajectories(
config_path,
video_paths,
filtered=True,
)
12. Create labeled videos#
deeplabcut.create_labeled_video(
config_path,
video_paths,
filtered=True,
)
This creates videos with the predicted keypoints overlaid, which is useful for a quick visual inspection of tracking quality.