DeepLabCut(CPU)学习过程及纠错

      菜狗学习动物姿态识别历程,非常艰辛但是感觉很有意思,在CSDN上面记录一下,希望能和大家交流。我是在笔记本电脑上配置的,只有一个垃圾集成显卡,安装也是按照仅有CPU的教程来的。

环境配置

      默认安装好anaconda,安装可以参考这篇文章https://blog.csdn.net/HowieXue/article/details/118442904

安装DLC

       GitHub官方下载链接:GitHub - DeepLabCut/DeepLabCut: Official implementation of DeepLabCut: Markerless pose estimation of user-defined features with deep learning for all animals incl. humans

DeepLabCut(CPU)学习过程及纠错_第1张图片

点击Download ZIP,解压在指定地方(建议别放C盘)

       然后打开anaconda navigation,点击Environments下面的Import

DeepLabCut(CPU)学习过程及纠错_第2张图片

       在解压的DEEPLABCUT\conda-environments找到DEEPLABCUT.yaml文件,点击Import就可以导入DEEPLABCUT了。导入需要的时间比较长,耐心等待一下

DeepLabCut(CPU)学习过程及纠错_第3张图片

       然后我在导入的时候出现了这个问题CondaEnvException: Pip failed,我去GitHub上面查了一下没找到确切的解决方法。我就去gitee上面下载一个版本较低的deeplabcut包,里面的yaml文件有两个版本,安装CPU版本的就可以了

       下载的链接:https://gitee.com/sanjunliu/DeepLabCut?_from=gitee_search

这次重新import就成功了

使用DLC

在创建项目的文件夹下打开Anaconda Powershell Prompt(以管理员身份运行),激活DLC环境

conda activate DLC(环境名)  #不知道的输入conda info --envs查看
ipython
import deeplabcut as dlc    #导入deeplabcut,可能会出现一些futurewarning,忽略即可

创建项目

#创建项目(项目名称,创建人,视频地址,复制视频)
dlc.create_new_project(r'DrinkWater',r'lqn',[r"E:\DeepLabCut-master\examples\Reaching-Mackenzie-2018-08-30\videos\reachingvideo1.avi"],copy_videos=True)

       项目的文件夹就可以在DeepLabCut里面找到了,打开项目里面的config.yaml文件,根据研究需要修改里面的参数

    # Project definitions (do not edit)
Task: DrinkWater
scorer: lqn
date: Jan24
multianimalproject: false

    # Project path (change when moving around)
project_path: E:\DeepLabCut-master\DrinkWater-lqn-2023-01-24   #项目路径

    # Annotation data set configuration (and individual video cropping parameters)
video_sets:
  E:\DeepLabCut-master\DrinkWater-lqn-2023-01-24\videos\reachingvideo1.avi:
    crop: 0, 832, 0, 747
bodyparts:  #关键点名称
- bodypart1
- bodypart2
- bodypart3
- objectA
start: 0
stop: 1
numframes2pick: 20     #关键帧的选择

    # Plotting configuration
skeleton:    #关键点的链接
- - bodypart1
  - bodypart2
- - objectA
  - bodypart3
skeleton_color: black   #链接线条的颜色
pcutoff: 0.6     #预测概率的置信区间
dotsize: 12     #关键点的大小
alphavalue: 0.7    #点的透明程度
colormap: plasma    #配色方案

    # Training,Evaluation and Analysis configuration
TrainingFraction:
- 0.95   #训练集的占比
iteration: 0    #迭代次数
default_net_type: resnet_50   #神经网络的类型
default_augmenter: default     #默认方案
snapshotindex: -1     #训练阶段模型的指标参数
batch_size: 8      #测试使用数据数量

    # Cropping Parameters (for analysis and outlier frame detection)
cropping: false
croppedtraining: false
    #if cropping is true for analysis, then set the values here:
x1: 0
x2: 640
y1: 277
y2: 624

    # Refinement configuration (parameters from annotation dataset configuration also relevant in this stage)
corner2move2:
- 50
- 50
move2corner: true

运行项目

根据需求修改了config.yaml文件后,可以开始运行项目

#工程路径设定
config_path = r"E:\DeepLabCut-master\DrinkWater-lqn-2023-01-24\config.yaml"
#自动提取数据帧
dlc.extract_frames(config_path)
dlc.label_frames(configpath)

       弹出交互界面后,在左下角的Load frames选择关键帧的文件夹,点击鼠标右键手工标记关键帧的关键点,最后点击save保存,点击quit退出(弹窗点击否)

DeepLabCut(CPU)学习过程及纠错_第4张图片

检查一下label是否完成

dlc.check_labels(config_path)

但是这里又出现了一些bug,我的图像是无效的,看了一下是因为通道数量太大了

DeepLabCut(CPU)学习过程及纠错_第5张图片

你可能感兴趣的:(学习,python,深度学习)