GithubHelp home page GithubHelp logo

jacke121 / bgscnn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saoyan/bgscnn

0.0 1.0 0.0 128 KB

Background subtraction using deep learning method.

License: GNU General Public License v3.0

Python 100.00%

bgscnn's Introduction

Background Subtraction Using Deep Learning Method

DOI


Recent Updates


You can find the details about my model in the following reports:

  1. Background Subtraction Using Deep Learning--Part I
  2. Background Subtraction Using Deep Learning--Part II
  3. Background Subtraction Using Deep Learning--Part III

A poster is also available. (The poster is only based on experiment results of v1~v3)
JPG version
PDF version

Contents of this repository

  • generate_bg.py
    generating background images; very time consuming to run
    You can get the preprocessed dataset from here.(If you have problem accessing Google Drive, please use this alternative link) Extract this and you will get a directory containing the original dataset with the generated background images. You can directly use it and run prepare_data.py.

  • prepare_data.py
    constructing TFrecords files for preparation of training the model

  • bgsCNN_v*.py
    training the model
    v1 ~ v3 respectively correspond to Model I ~ III mentioned in the second report; v4, v5 haven't been included in reports yet

How to run

1. Dependences

  • Tensorflow
  • OpenCV compiled with Python support (you can refer to this repository for compiling OpenCV)
  • bgslibrary (needed only if you want to run generate_bg.py yourself)
  • Downloaded Checkpoint file of ResNet_V2_50 from Tensorflow Model Zoo, and put resnet_v2_50.ckpt at the same directory as Python script files.
  • Downloaded Checkpoint file of vgg_16 from Tensorflow Model Zoo, and put vgg_16.ckpt at the same directory as Python script files.

2. Training


NOTE
If you use bgsCNN_v1, v2 or v3, set the image_height & image_width as multiples of 32 plus 1, e.g. 321.
If you use bgsCNN_v4 or v5, set the image_height & image_width as multiples of 32, e.g. 320.


In the following demos, suppose we use bgsCNN_v2.

  • If you want to run both generate_bg.py and prepare_data.py (trust me, you don't want to run generate_bg.py yourself!):
python train.py \
  --generate_bg True \
  --prepare_data True  \
  --dataset_dir dataset \
  --log_dir logs \
  --model_version 2 \
  --image_height 321 \
  --image_width 321 \
  --train_batch_size 40 \
  --test_batch_size 200 \
  --max_iteration 10000
  • If you've downloaded the dataset I provided and don't need to run generate_bg.py (suppose the downloaded data is stored in directory "dataset"):
python train.py \
  --prepare_data True  \
  --dataset_dir dataset \
  --log_dir logs \
  --model_version 2 \
  --image_height 321 \
  --image_width 321 \
  --train_batch_size 40 \
  --test_batch_size 200 \
  --max_iteration 10000
  • If you've already had the TFrecords files and don't want to tun prepare_data.py (suppose the two TFrecords files are train.tfrecords & test.tfrecords):
python train.py \
  --prepare_data False  \
  --train_file train.tfrecords \
  --test_file test.tfrecords \
  --log_dir logs \
  --model_version 2 \
  --image_height 321 \
  --image_width 321 \
  --train_batch_size 40 \
  --test_batch_size 200 \
  --max_iteration 10000

3. Test on the test set

When you've finished the training, you can evaluate the model on test to see average test loss. The logs of this test procedure will be in sub-directory "model_test" under your identified logs directory.

python test.py \
  --test_file test.tfrecords \
  --log_dir logs \
  --model_version 2 \
  --image_height 321 \
  --image_width 321 \
  --optimal_step 9600

4. Test on video

You can also run the model on your own video.

python test_on_video.py \
  --log_dir logs \
  --model_version 2 \
  --image_height 321 \
  --image_width 321 \
  --video_file test.mp4
  --optimal_step 9600

bgscnn's People

Contributors

saoyan avatar

Watchers

 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.