【SlowFast复现】Windows10配置SlowFast环境全过程 并使用自己的视频进行demo检测
2022/3/22 7:32:13
本文主要是介绍【SlowFast复现】Windows10配置SlowFast环境全过程 并使用自己的视频进行demo检测,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Windows10配置SlowFast环境全过程 并使用自己的视频进行demo检测
- 环境简介
- 1. 开始配置
- 2.配置demo环境
- 3. 测试结果
环境简介
pycharm
python=3.7.11
我就是不用linux,就要用window10配置。
你还需要安装git,下下来以后一直下一步即可。
可能还需要Visual Studio。
1. 开始配置
首先下载官网的代码库
git clone https://github.com/facebookresearch/slowfast cd SlowFast
然后新建一个虚拟环境。
然后自己安装 pytorch 和 torchvision 对应cuda的GPU版本。
接下来就按我给的安装提示一步一步的安装。
# 要双引号!!!!!!! pip install 'git+https://github.com/facebookresearch/fvcore' pip install 'git+https://github.com/facebookresearch/fairscale' pip install simplejson pip install -U iopath pip install psutil,tensorboard,opencv-python,moviepy,moviepy,pytorchvideo pip install pillow,pyyaml,pandas,matplotlib,sklearn
其中Detection2的安装可以按这个:
git clone https://github.com/facebookresearch/detectron2.git python -m pip install -e detectron2
千万要有耐心,一步一步走。
接下来就是就是编译:
python setup.py build develop
如果没报错的话就代表没有错误,如果报错了就代表有错误(听君一席话,,,),即使评论错误提示。
2.配置demo环境
终于到了测试自己视频的环节。
在主目录下/demo/AVA下新建ava.json,复制下面的标签到里面。
ava.json
{"bend/bow (at the waist)": 0, "crawl": 1, "crouch/kneel": 2, "dance": 3, "fall down": 4, "get up": 5, "jump/leap": 6, "lie/sleep": 7, "martial art": 8, "run/jog": 9, "sit": 10, "stand": 11, "swim": 12, "walk": 13, "answer phone": 14, "brush teeth": 15, "carry/hold (an object)": 16, "catch (an object)": 17, "chop": 18, "climb (e.g., a mountain)": 19, "clink glass": 20, "close (e.g., a door, a box)": 21, "cook": 22, "cut": 23, "dig": 24, "dress/put on clothing": 25, "drink": 26, "drive (e.g., a car, a truck)": 27, "eat": 28, "enter": 29, "exit": 30, "extract": 31, "fishing": 32, "hit (an object)": 33, "kick (an object)": 34, "lift/pick up": 35, "listen (e.g., to music)": 36, "open (e.g., a window, a car door)": 37, "paint": 38, "play board game": 39, "play musical instrument": 40, "play with pets": 41, "point to (an object)": 42, "press": 43, "pull (an object)": 44, "push (an object)": 45, "put down": 46, "read": 47, "ride (e.g., a bike, a car, a horse)": 48, "row boat": 49, "sail boat": 50, "shoot": 51, "shovel": 52, "smoke": 53, "stir": 54, "take a photo": 55, "text on/look at a cellphone": 56, "throw": 57, "touch (an object)": 58, "turn (e.g., a screwdriver)": 59, "watch (e.g., TV)": 60, "work on a computer": 61, "write": 62, "fight/hit (a person)": 63, "give/serve (an object) to (a person)": 64, "grab (a person)": 65, "hand clap": 66, "hand shake": 67, "hand wave": 68, "hug (a person)": 69, "kick (a person)": 70, "kiss (a person)": 71, "lift (a person)": 72, "listen to (a person)": 73, "play with kids": 74, "push (another person)": 75, "sing to (e.g., self, a person, a group)": 76, "take (an object) from (a person)": 77, "talk to (e.g., self, a person, a group)": 78, "watch (a person)": 79}
然后下载官网权重文件
打开/demo/AVA/SLOWFAST_32x2_R101_50_50.yaml将我的配置信息粘贴进去
TRAIN: ENABLE: False DATASET: ava BATCH_SIZE: 16 EVAL_PERIOD: 1 CHECKPOINT_PERIOD: 1 AUTO_RESUME: True # 刚刚下载的官方权重文件的路径 CHECKPOINT_FILE_PATH: 'D:/python/video_classify/SlowFast-main/weights/SLOWFAST_32x2_R101_50_50.pkl' #path to pretrain model CHECKPOINT_TYPE: pytorch DATA: NUM_FRAMES: 32 SAMPLING_RATE: 2 TRAIN_JITTER_SCALES: [256, 320] TRAIN_CROP_SIZE: 224 TEST_CROP_SIZE: 256 INPUT_CHANNEL_NUM: [3, 3] DETECTION: ENABLE: True ALIGNED: False AVA: BGR: False DETECTION_SCORE_THRESH: 0.8 TEST_PREDICT_BOX_LISTS: ["person_box_67091280_iou90/ava_detection_val_boxes_and_labels.csv"] SLOWFAST: ALPHA: 4 BETA_INV: 8 FUSION_CONV_CHANNEL_RATIO: 2 FUSION_KERNEL_SZ: 5 RESNET: ZERO_INIT_FINAL_BN: True WIDTH_PER_GROUP: 64 NUM_GROUPS: 1 DEPTH: 101 TRANS_FUNC: bottleneck_transform STRIDE_1X1: False NUM_BLOCK_TEMP_KERNEL: [[3, 3], [4, 4], [6, 6], [3, 3]] SPATIAL_DILATIONS: [[1, 1], [1, 1], [1, 1], [2, 2]] SPATIAL_STRIDES: [[1, 1], [2, 2], [2, 2], [1, 1]] NONLOCAL: LOCATION: [[[], []], [[], []], [[6, 13, 20], []], [[], []]] GROUP: [[1, 1], [1, 1], [1, 1], [1, 1]] INSTANTIATION: dot_product 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]]] BN: USE_PRECISE_STATS: False NUM_BATCHES_PRECISE: 200 SOLVER: MOMENTUM: 0.9 WEIGHT_DECAY: 1e-7 OPTIMIZING_METHOD: sgd MODEL: NUM_CLASSES: 80 ARCH: slowfast MODEL_NAME: SlowFast LOSS_FUNC: bce DROPOUT_RATE: 0.5 HEAD_ACT: sigmoid TEST: ENABLE: False DATASET: ava BATCH_SIZE: 8 DATA_LOADER: NUM_WORKERS: 2 PIN_MEMORY: True NUM_GPUS: 1 NUM_SHARDS: 1 RNG_SEED: 0 OUTPUT_DIR: . #TENSORBOARD: # MODEL_VIS: # TOPK: 2 DEMO: ENABLE: True LABEL_FILE_PATH: "./demo/AVA/ava.json" #刚刚生成的label文件 INPUT_VIDEO: "./input/1.mp4" #视频输入路径 OUTPUT_FILE: "./output/1.mp4" #视频输出路径 DETECTRON2_CFG: "COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml" DETECTRON2_WEIGHTS: detectron2://COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/model_final_280758.pkl
注意修改,权重文件的路径,label文件的路径,输入视频的路径以及输出视频的路径
3. 测试结果
这样就代表demo运行成功。
结果展示
<iframe allowfullscreen="true" data-mediaembed="bilibili" id="t5gaYF6j-1647836515681" src="https://player.bilibili.com/player.html?aid=297441981"></iframe>Windows10配置SlowFast环境全过程 并使用自己的视频进行demo检测
看起来是不是很简单呢。
有什么问题,及时评论留言。
这篇关于【SlowFast复现】Windows10配置SlowFast环境全过程 并使用自己的视频进行demo检测的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-26Mybatis官方生成器资料详解与应用教程
- 2024-11-26Mybatis一级缓存资料详解与实战教程
- 2024-11-26Mybatis一级缓存资料详解:新手快速入门
- 2024-11-26SpringBoot3+JDK17搭建后端资料详尽教程
- 2024-11-26Springboot单体架构搭建资料:新手入门教程
- 2024-11-26Springboot单体架构搭建资料详解与实战教程
- 2024-11-26Springboot框架资料:新手入门教程
- 2024-11-26Springboot企业级开发资料入门教程
- 2024-11-26SpringBoot企业级开发资料详解与实战教程
- 2024-11-26Springboot微服务资料:新手入门全攻略