GithubHelp home page GithubHelp logo

xavieryu404 / tumblerelf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from desertfex/tumblerelf

0.0 0.0 0.0 164.01 MB

Human fall detection.

Python 89.18% Shell 0.42% C++ 3.46% Cuda 6.81% Dockerfile 0.10% Makefile 0.04%

tumblerelf's Introduction

代码说明

1. 代码总体情况

本项目代码基于detectron2 进行的二次开发. 因此运行该项目的前提是先安装detectron2, 但是由于我们对detectron2 的代码功能做了一些小的改动, 所以需要按照下面的步骤安装.

2. 安装项目依赖

2.1 detectron2 的依赖安装

  • Linux with Python ≥ 3.6
  • PyTorch ≥ 1.3
  • torchvision that matches the PyTorch installation. You can install them together at pytorch.org to make sure of this.
  • OpenCV, optional, needed by demo and visualization
  • pycocotools: pip install cython; pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'

2.2 本项目修改版 detectron2 安装

# 进入项目主文件夹 person-fallcnt
# 然后执行以下命令
$ cd detectron2
$ pip install -e .
# 如果上面命令遇到权限问题, 加上--user

如果安装遇到错, 可查看install.md ,或者联系我们团队进行解决。

3. 代码运行

训练

训练程序接口文件为pfallcnt_train.py 。训练方式和参数如下示例。

# 训练 faster_rcnn_R_50_FPN
$ python3 pfallcnt_train.py --datapth path_to_the_training_set --outdir path_to_training_output --max_iters 200000
# 训练 faster_rcnn_X_101_32x8d_FPN 模型
$ python3 pfallcnt_train.py --cfg faster_rcnn_X_101_32x8d_FPN_3x.yaml --datapath path_to_the_training_set --outdir path_to_training_output --max_iters 200000
# 训练 cascade_mask_rcnn_x_152_FPN
$ python3 pfallcnt_train.py --cfg_dir Misc/ --cfg cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml --datapath path_to_the_training_set --outdir path_to_training_output --max_iters 200000

demo运行

测试程序接口文件为 demo.py ,运行方式如下示例。

# 用单个模型测试
$ python3 demo.py --input_type 0(or 1 or 2 or 3) --cfg_dir COCO-Detection/(or Misc/) --cfg model_config_file --res_dir path_to_testing_result(can be None or "", if None or "". it requires opencv and desktop enviroment) --model_url model_file --min_size image_size --input input_file_or_directory
#########################################################################################
# 比如: 用cascade_mask_rcnn_X_152_FPN 对视频进行预测
$ python3 demo.py --cfg_dir Misc --cfg cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml --res_dir results --model_url mmodels/cascade_x152_model.pth --input test_data/test_0.mp4
# 比如: 用 faster_rcnn_X_101_32x8d_FPN 进行预测
$ python3 demo.py --cfg faster_rcnn_X_101_32x8d_FPN_3x.yaml --res_dir results --model_url models/faster_x101_model.pth --input test_data/test_0.mp4
# 比如: 用cascade_mask_rcnn_X_152_FPN 对某个文件夹下面的图片进行预测
$ python3 demo.py --cfg_dir Misc --cfg cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml --res_dir results --model_url mmodels/cascade_x152_model.pth --input_type 2 --input test_data/images/
# 比如: 用cascade_mask_rcnn_X_152_FPN 对摄像头视频流进行预测,此时只能在桌面环境进行可视化,不支持保存到文件。
$ python3 demo.py --cfg_dir Misc --cfg cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml --model_url mmodels/cascade_x152_model.pth --input_type 1

更多参数的细节,请使用--help参数获得。

注1: 由于对demo程序的测试没有桌面环境,因此无法测试直接可视化的过程(即只测试了把检测结果保存到文件的部分),因此无法保证可视化部分一定可以顺利运行,如果遇到问题,请联系解决。

注2: 由于模型参数文件过大, 因此提交的文件并不包含训练好的模型. 需要可以联系发送。

3.1 训练数据格式

训练集文件夹里面应该包含图片数据和bbox标注数据, bbox标注数据问json文件, 图片为jpg格式.

bbox标注数据文件格式如下:

{
  "version": "4.2.7",
  "flags": {},
  "shapes": [
    {
      "gound_id": null,
      "label": "1",
      "points": [
        [
          340.9351501464844,
          147.46168518066406
        ],
        [
          538.90576171875,
          214.04153442382812
        ]
      ],
      "group_id": null,
      "shape_type": "rectangle",
      "flags": {}
    },
    {
      "gound_id": null,
      "label": "0",
      "points": [
        [
          186.7875518798828,
          36.57759094238281
        ],
        [
          216.6598358154297,
          110.41905212402344
        ]
      ],
      "group_id": null,
      "shape_type": "rectangle",
      "flags": {}
    }
  ],
  "imagePath": "./tr-1.jpg",
  "imageData": null,
  "imageHeight": 302,
  "imageWidth": 550,
  "flag": {}
}

tumblerelf's People

Contributors

iyuqinl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.