import json
from pathlib import Path

import numpy as np
import pandas as pd

import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
set_session(tf.Session(config=config))

from keras.models import Sequential, Model
from keras.preprocessing import image
from keras.layers import *
from keras.optimizers import *

from data import window_generator
from utils import get_callbacks


def main():
    model = Sequential()
    model.add(TimeDistributed(BatchNormalization(), input_shape=(10, 224, 224, 3)))
    model.add(TimeDistributed(Conv2D(4, kernel_size=5, strides=3, activation='relu')))
    model.add(TimeDistributed(Conv2D(8, kernel_size=5, strides=2, activation='relu')))
    model.add(TimeDistributed(Conv2D(12, kernel_size=3, strides=1, activation='relu')))
    model.add(TimeDistributed(MaxPooling2D(pool_size=3)))
    model.add(Flatten())
    model.add(Dense(30))
    model.add(Dropout(0.3))
    model.add(Dense(1, activation='sigmoid'))

    model_arg = {
        'loss': 'binary_crossentropy',
        'optimizer': 'sgd',
        'metrics': ['binary_accuracy']
    }
    model.compile(**model_arg)
    model.summary()

    # n_train = 25000
    # n_val = 5000
    # batch_size = 40

    # dataset = Path('~/dataset/').expanduser().resolve()
    # video_dirs = sorted([x for x in dataset.iterdir() if x.is_dir()])
    # train_dirs = [(dataset / 'video01/')]
    # val_dirs = [(dataset / 'video00')]
    # train_gen = image_generator(train_dirs, n_train, batch_size)
    # val_gen = image_generator(val_dirs, n_val, batch_size)

    # fit_arg = {
    #     'generator': train_gen,
    #     'steps_per_epoch': n_train // batch_size,
    #     'epochs': 30,
    #     'validation_data': val_gen,
    #     'validation_steps': n_val // batch_size,
    #     'callbacks': get_callbacks('convlstm')
    # }

    # model.fit_generator(**fit_arg)


if __name__ == '__main__':
    main()
@@ -1216,18 +1216,16 @@
 y()%0A%0A   
- #
  n_train
@@ -1236,18 +1236,16 @@
 5000%0A   
- #
  n_val =
@@ -1253,18 +1253,16 @@
 5000%0A   
- #
  batch_s
@@ -1274,18 +1274,16 @@
  40%0A%0A   
- #
  dataset
@@ -1330,18 +1330,16 @@
 ve()%0A   
- #
  video_d
@@ -1396,26 +1396,24 @@
 _dir()%5D)%0A   
- #
  train_dirs 
@@ -1438,26 +1438,24 @@
 eo01/')%5D%0A   
- #
  val_dirs = 
@@ -1481,18 +1481,16 @@
 0')%5D%0A   
- #
  train_g
@@ -1546,18 +1546,16 @@
 ize)%0A   
- #
  val_gen
@@ -1606,18 +1606,16 @@
 ze)%0A%0A   
- #
  fit_arg
@@ -1618,26 +1618,24 @@
 _arg = %7B%0A   
- #
      'genera
@@ -1655,22 +1655,20 @@
 en,%0A    
-#
     
- 
 'steps_p
@@ -1700,26 +1700,24 @@
 ch_size,%0A   
- #
      'epochs
@@ -1723,30 +1723,28 @@
 s': 30,%0A    
-#
     
- 
 'validation_
@@ -1758,26 +1758,24 @@
 val_gen,%0A   
- #
      'valida
@@ -1811,18 +1811,16 @@
 ize,%0A   
- #
      'ca
@@ -1862,19 +1862,15 @@
 %0A   
- #
  %7D%0A%0A   
- #
  mod

Update at 2017-07-14 20-57-36