DeepLabCut Workflow

Download the Video From Google Drive#

  • A video will be assigned to you. You will recieve an email with a link to the folder that has the video or I will specificly point to a video that you can download.

Run DeepLabCut GUI#

# On MacOS/Linux open a terminal window. On Windows, open Anaconda Prompt
$ conda activate DLC-CPU
$ pythonw # on Windows: $ ipython
>>> import deeplabcut
>>> deeplabcut.launch_dlc()

Create New Project#

Tab: Manage Project

  • Type the name of the project and your name.
  • Select the video you want to use for the current project.
  • Check the first box, then click 'Browse' and choose a directory that you can remember (typically your desktop).
  • Check the second box.

Modify Config File Parameters#

  • Open your project folder.
  • Open Config.yaml file.
  • Change label names under bodyparts: and skeleton: (names depend on the current project).
  • Change pcutoff: to 0.9.
# Default config.yaml
# These are the parameters that you will need to change
bodyparts:
- bodypart1
- bodypart2
- objectA
- bodypart3
.
.
.
skeleton:
- - bodypart1
- bodypart2
- - objectA
- bodypart3
pcutoff: 0.6

Extract Frames#

Tab: Extract Frames

  • Keep the defaults then hit "Ok".

Wait until all processes are completed. When completed, you will see the following message:

Frames were successfully extracted.

You can now label the frames using the function 'label_frames' (if you extracted enough frames for all videos).

Label Frames#

Tab: Label Frames

  • Click on Label Frames button in the bottom.

  • Label the body parts.
  • When you are done, save then quit.

Build Skeleton#

Tab: Label Frames

  • Click on Build Skeleton button in the bottom.
  • Drag your mouse on the points in the correct order to draw a line that defines the skeleton.
  • Hit Export, then close the window.

  • Close DeepLabCut interface, then hit CTRL+C in your terminal.

Clean Labeled Data#

  • Open the .csv file under your project folder → labeled-data → video-name folder → CollectedData<name>.csv.
  • If you skipped any frame, you will notice that some rows have no data.
  • Delete any image that does not have any data in the .csv file (the images name are in the first column of the .csv file, and the actual images can be found under the same folder you found your .csv file in).
  • When you are done deleting the actual images (don't edit the .csv file!), open a new terminal window and run the following:
$ conda activate DLC-CPU
$ pythonw # on Windows: $ ipython
>>> import deeplabcut
>>> cfg = '<config_file_path>'
>>> deeplabcut.dropannotationfileentriesduetodeletedimages(cfg)

Change Paths#

Next, we will change all the paths in the configuration file to match the cluster's.

  • Open your project folder.
  • Open Config.yaml file.
  • Change the paths under project_path: and video_sets to match the cluster's directory. For example:

The following paths

# Example
project_path: /Users/Duck/Desktop/<project>
video_sets:
/Users/Duck/Desktop/<project>/videos/<video>.mp4:

will be changed to:

# Example
project_path: /work/chaselab/<username>/<project>
video_sets:
/work/chaselab/<username>/<project>/videos/<video>.mp4:
note

On windows, make sure you change all back slashes "\" to forward slashes "/".

  • Save and close.

Upload Your Project Folder to Google Drive#

  • Open your school's account on Google Drive.
  • Drag and drop the folder to the same shared folder you downloaded the video from.
  • Wait for the upload to complete.

Log in to the Cluster#

  • Now log in to the cluster:
$ ssh <username>@crane.unl.edu
  • Call your "DLC environment kit":
$ source i.sh
  • Start a tmux session.
$ tmux # if you have an active tmux session, run: $ tmux a

Copy Your Project Folder to the Cluster#

You will use Rclone to copy your project folder from Google Drive to the cluster. Do this by running:

$ rclone --drive-shared-with-me copy drive:</path/to/project> ./<project>
note

The </path/to/project> can be viewed at the top of the Google Drive page.

For example, this:

will be:

# Example
$ rclone --drive-shared-with-me copy drive:/may20/catcat_10-08-2020 ./catcat_10-08-2020

Copy to Shared#

  • When the folder is downloaded to the cluster, make a copy to chaselab group's shared folder. To do this, simply run:
$ cp -avr $WORK/<project> /work/chaselab/shared/toxo-project/DLC-DATA-SHARE/<project>

     Done!   




Related External Links/Sources:#