当前位置:   article > 正文

[深度学习][原创]使用labelImg+yolov5完成所有slowfast时空动作检测项目-训练测试篇_slowfast模型训练参数

slowfast模型训练参数

当我们准备好训练集和配置文件后就可以着手训练的事情了。首先安装好slowfast环境,然后打开源码,slowfast/configs/AVA/SLOWFAST_32x2_R50_SHORT.yaml作如下配置

  1. TRAIN:
  2. ENABLE: True
  3. DATASET: ava
  4. BATCH_SIZE: 4
  5. EVAL_PERIOD: 5
  6. CHECKPOINT_PERIOD: 1
  7. AUTO_RESUME: True
  8. # CHECKPOINT_FILE_PATH: /home/fut/Downloads/slowfast/pre-model/SLOWFAST_32x2_R101_50_50.pkl
  9. CHECKPOINT_TYPE: caffe2
  10. DATA:
  11. NUM_FRAMES: 32
  12. SAMPLING_RATE: 2
  13. TRAIN_JITTER_SCALES: [256, 320]
  14. TRAIN_CROP_SIZE: 224
  15. TEST_CROP_SIZE: 224
  16. INPUT_CHANNEL_NUM: [3, 3]
  17. PATH_TO_DATA_DIR: './myava'
  18. DETECTION:
  19. ENABLE: True
  20. ALIGNED: True
  21. AVA:
  22. FRAME_DIR: 'myava/frame'
  23. FRAME_LIST_DIR: 'myava/frame_lists'
  24. ANNOTATION_DIR: 'myava/annotations'
  25. DETECTION_SCORE_THRESH: 0.8
  26. TRAIN_PREDICT_BOX_LISTS: [
  27. "ava_train_v2.2.csv",
  28. "person_box_67091280_iou90/ava_detection_train_boxes_and_labels_include_negative_v2.2.csv",
  29. ]
  30. TEST_PREDICT_BOX_LISTS: ["person_box_67091280_iou90/ava_detection_val_boxes_and_labels.csv"]
  31. SLOWFAST:
  32. ALPHA: 4
  33. BETA_INV: 8
  34. FUSION_CONV_CHANNEL_RATIO: 2
  35. FUSION_KERNEL_SZ: 7
  36. RESNET:
  37. ZERO_INIT_FINAL_BN: True
  38. WIDTH_PER_GROUP: 64
  39. NUM_GROUPS: 1
  40. DEPTH: 50
  41. TRANS_FUNC: bottleneck_transform
  42. STRIDE_1X1: False
  43. NUM_BLOCK_TEMP_KERNEL: [[3, 3], [4, 4], [6, 6], [3, 3]]
  44. SPATIAL_DILATIONS: [[1, 1], [1, 1], [1, 1], [2, 2]]
  45. SPATIAL_STRIDES: [[1, 1], [2, 2], [2, 2], [1, 1]]
  46. NONLOCAL:
  47. LOCATION: [[[], []], [[], []], [[], []], [[], []]]
  48. GROUP: [[1, 1], [1, 1], [1, 1], [1, 1]]
  49. INSTANTIATION: dot_product
  50. POOL: [[[1, 2, 2], [1, 2, 2]], [[1, 2, 2], [1, 2, 2]], [[1, 2, 2], [1, 2, 2]], [[1, 2, 2], [1, 2, 2]]]
  51. BN:
  52. USE_PRECISE_STATS: False
  53. NUM_BATCHES_PRECISE: 200
  54. SOLVER:
  55. BASE_LR: 0.1
  56. LR_POLICY: steps_with_relative_lrs
  57. STEPS: [0, 10, 15, 20]
  58. LRS: [1, 0.1, 0.01, 0.001]
  59. MAX_EPOCH: 300
  60. MOMENTUM: 0.9
  61. WEIGHT_DECAY: 1e-7
  62. WARMUP_EPOCHS: 5.0
  63. WARMUP_START_LR: 0.000125
  64. OPTIMIZING_METHOD: sgd
  65. MODEL:
  66. NUM_CLASSES: 2
  67. ARCH: slowfast
  68. MODEL_NAME: SlowFast
  69. LOSS_FUNC: bce
  70. DROPOUT_RATE: 0.5
  71. HEAD_ACT: sigmoid
  72. TEST:
  73. ENABLE: True
  74. DATASET: ava
  75. BATCH_SIZE: 8
  76. DATA_LOADER:
  77. NUM_WORKERS: 2
  78. PIN_MEMORY: True
  79. NUM_GPUS: 4
  80. NUM_SHARDS: 1
  81. RNG_SEED: 0
  82. OUTPUT_DIR: .

1 TRAIN:CHECKPOINT_FILE_PATH 就是我们下载的与训练模型的位置
2 DATA:PATH_TO_DATA_DIR 就是我们第二部分制作的数据集文件
3 AVA: 下面的路径也是对应第二部分数据集文件对应的地方
4 MODEL:NUM_CLASSES: 1 这里是最需要主义的,这里classes必需为2,因为我们有fight和person 2个分类。

开始训练:

 python tools/run_net.py --cfg configs/AVA/SLOWFAST_32x2_R50_SHORT5.yaml
训练出来的模型文件在chekpoints文件里面,我截图看看

惊喜不?是pyth格式文件,后面我们开始测试模型效果

首先 新建slowfast/demo/AVA/SLOWFAST_32x2_R50_SHORT.yaml文件,写下面代码

  1. TRAIN:
  2. ENABLE: False
  3. DATASET: ava
  4. BATCH_SIZE: 1
  5. EVAL_PERIOD: 1
  6. CHECKPOINT_PERIOD: 1
  7. AUTO_RESUME: True
  8. CHECKPOINT_FILE_PATH: 'checkpoints/checkpoint_epoch_00140.pyth' #path to pretrain model
  9. CHECKPOINT_TYPE: pytorch
  10. DATA:
  11. NUM_FRAMES: 16
  12. SAMPLING_RATE: 2
  13. TRAIN_JITTER_SCALES: [256, 320]
  14. TRAIN_CROP_SIZE: 224
  15. TEST_CROP_SIZE: 256
  16. INPUT_CHANNEL_NUM: [3, 3]
  17. DETECTION:
  18. ENABLE: True
  19. ALIGNED: False
  20. AVA:
  21. BGR: False
  22. DETECTION_SCORE_THRESH: 0.8
  23. TEST_PREDICT_BOX_LISTS: ["person_box_67091280_iou90/ava_detection_val_boxes_and_labels.csv"]
  24. SLOWFAST:
  25. ALPHA: 4
  26. BETA_INV: 8
  27. FUSION_CONV_CHANNEL_RATIO: 2
  28. FUSION_KERNEL_SZ: 5
  29. RESNET:
  30. ZERO_INIT_FINAL_BN: True
  31. WIDTH_PER_GROUP: 64
  32. NUM_GROUPS: 1
  33. DEPTH: 101
  34. TRANS_FUNC: bottleneck_transform
  35. STRIDE_1X1: False
  36. NUM_BLOCK_TEMP_KERNEL: [[3, 3], [4, 4], [6, 6], [3, 3]]
  37. SPATIAL_DILATIONS: [[1, 1], [1, 1], [1, 1], [2, 2]]
  38. SPATIAL_STRIDES: [[1, 1], [2, 2], [2, 2], [1, 1]]
  39. NONLOCAL:
  40. LOCATION: [[[], []], [[], []], [[6, 13, 20], []], [[], []]]
  41. GROUP: [[1, 1], [1, 1], [1, 1], [1, 1]]
  42. INSTANTIATION: dot_product
  43. POOL: [[[2, 2, 2], [2, 2, 2]], [[2, 2, 2], [2, 2, 2]], [[2, 2, 2], [2, 2, 2]], [[2, 2, 2], [2, 2, 2]]]
  44. BN:
  45. USE_PRECISE_STATS: False
  46. NUM_BATCHES_PRECISE: 200
  47. SOLVER:
  48. MOMENTUM: 0.9
  49. WEIGHT_DECAY: 1e-7
  50. OPTIMIZING_METHOD: sgd
  51. MODEL:
  52. NUM_CLASSES: 2
  53. ARCH: slowfast
  54. MODEL_NAME: SlowFast
  55. LOSS_FUNC: bce
  56. DROPOUT_RATE: 0.5
  57. HEAD_ACT: sigmoid
  58. TEST:
  59. ENABLE: False
  60. DATASET: ava
  61. BATCH_SIZE: 1
  62. DATA_LOADER:
  63. NUM_WORKERS: 2
  64. PIN_MEMORY: True
  65. NUM_GPUS: 1
  66. NUM_SHARDS: 1
  67. RNG_SEED: 0
  68. OUTPUT_DIR: .
  69. #TENSORBOARD:
  70. # MODEL_VIS:
  71. # TOPK: 2
  72. DEMO:
  73. ENABLE: True
  74. LABEL_FILE_PATH: "myava/annotations/myava.json"
  75. INPUT_VIDEO: "myava/videos/fight1.mp4"
  76. OUTPUT_FILE: "myava/fight1_out.mp4"
  77. DETECTRON2_CFG: "COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml"
  78. DETECTRON2_WEIGHTS: detectron2://COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/model_final_280758.pkl

由于我的显存6GB老是out of memory于是设置NUM_FRAMES为16,如果你显存够可以设置32,这个是默认值。

测试开始:

python tools/run_net.py --cfg demo/AVA/SLOWFAST_32x2_R50_SHORT.yaml

稍等一会结果就出来了。最终效果还可以。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/325395
推荐阅读
相关标签
  

闽ICP备14008679号