Home

Awesome

Background Subtraction Using Deep Learning Method

DOI


Most Recent Updates
May 23, 2018: Some pre-trained models are released.


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)
Get poster

Pre-trained models

Unfortunately, pre-trained models of v1 and v4 are missing :(
Version 2
Version 3
Version 5

Contents of this repository

How to run

1. Dependences

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.

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
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
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