DLC

Local Environment building(GPU Version)

My environment version

  • conda
  • cuda
  • cudnn
  • cudatoolkit
  • torch
  • torchaudio
  • torchvision
  • Visual Studio 2022
  • 4070TS 16G显存

How to SETUP

Way 1

  1. Download the .yaml file locally from the Deeplabcut home page

  2. 1
    2
    cd Path_to_your_yaml_file
    conda env create -f DEEPLABCUT.yaml
  3. If errors occur, you can use

    1
    conda env update -f DEEPLABCUT.yaml

    to continue to create your env or update your env

  4. If the cuda version is still CPU, then you need to install pytorch gpu version correctly(refer to Way 3)

Way 2

  1. Download the .yaml file

  2. Import .yaml file in the anaconda console to create the target env directly

Way 3(Recommend)

1
2
3
4
5
6
conda create -n deeplabcut3 python=3.10
conda activate deeplabcut3
conda install pytorch cudatoolkit=11.8 -c pytorch
conda install -c conda-forge pytables==3.8.0
pip install "git+https://github.com/DeepLabCut/DeepLabCut.git@pytorch_dlc#egg=deeplabcut[gui,modelzoo,wandb]"
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

How to Check Pytorch Version

1
2
3
4
5
python
>>import torch
>>print(__torch.version__)
>>print(torch.cuda.is_available())
>>print(torch.cuda.device_count())

How to Start

1
python -m deeplabcut

How to Use

  1. Prepare your videos

  2. Edit the config file

    • Define your keypoints and skeletons
    • Define your extracted frame number
    • Define your cut off probability
    • Define your engine type
    • Define your label parameters
  3. Extract Frames

    • Uniform: pick uniform frames
    • Kmeans: pick key frames
  4. Label Frames(Napari GUI)

    • You need to label exactly, because it will have a significant influence on your training dataset and the final effect.
    • Generate a csv file, saving the pixel position of keypoints
  5. Check Labels

    • Generate Labeled pictures
      Labeled_pict
  6. Create Training Dataset

    • Choose your network and create the corresponding dataset
  7. Training Model

    • Edit training config file
      • Batch size: Improve the training speed, but need enough 显存
      • Learning rate: Choose correct lr. Too low, the longer training time. Too high, lead to the vibration problem, which means lower performance.
      • Display iteration/Save epoches/Max snapshots
      • Runner
        • Load weights: False(Be careful!!!)
    • You can load your trained snapshots to improve your models
  8. Evaluate Model

    • Metrics
      • RMSE
      • MAP
      • MAR
        Evaluate_pict
  9. Analyse Video

    • Choose your target original video
    • If your 显存 enough, you can increase your batch size to accelerate the process.
  10. Create Video

    • Choose correct cutoff value to get the final predicted video.
  11. Improve Labels

    • Refine your old labeled frames
    • Add new labeled frames
    • Create new training dataset

QA

  1. CPU version can directly use but too slow, and if you want to use GPU version which is ten times faster than the former, you need to be careful to prepare your env. Many types of combination will lead to some tricky problems. Following the Way 3 is the most correct way to prepare your env.

  2. While labeling, you need to label exactly. Otherwise, the keypoints in the created video will vibrate in a range.

  3. While training, default parameters are well.

  4. While creating video, if the final predicted video doesnot contain any plot, you need to change your cutoff value.

  5. If you want to reuse your labeled data, you need to create a same name project and change a small part of content in CSV file.

  6. Old versions of deeplabcut still have some problems and different versions can’t be mixed.

Comparison

  1. DEEPLABCUT
  2. DEEPSHAPEKIT
  3. SLEAP