def build_deepvo(inputs,
                 is_training,
                 seq_length,
                 height,
                 width,
                 scope='deepvo'):
    # print (inputs)
    # inputs_list = tf.unstack(inputs)
    # for inputs in inputs_list:
    #     pred = build_flownet(inputs, is_training=is_training)
    #
    with tf.variable_scope('timedistruted_cnn', reuse=tf.AUTO_REUSE):
        print(inputs)
        inputs = tf.reshape(inputs, (1, seq_length, height, width, 2))
        net = core.input_data(shape=(None, seq_length, height, width, 2),
                              placeholder=inputs)
        net = core.time_distributed(net, build_flownet, [inputs])
        # net = core.time_distributed(net, conv.conv_2d, [32, 7, 2, 'same', 'relu'])
        # net = core.time_distributed(net, conv.conv_2d, [64, 5, 2, 'same', 'relu'])
        # net = core.time_distributed(net, conv.conv_2d, [128, 3, 2, 'same', 'relu'])
        # net = core.time_distributed(net, conv.conv_2d, [256, 3, 2, 'same', 'relu'])
        # net = core.time_distributed(net, conv.conv_2d, [256, 3, 2, 'same', 'relu'])
        # net = core.time_distributed(net, conv.conv_2d, [256, 3, 2, 'same', 'relu'])
        net = core.time_distributed(net, conv.global_max_pool)
    with tf.variable_scope('rnn'):
        net = recurrent.lstm(net,
                             n_units=124,
                             activation=tf.nn.relu,
                             return_seq=True,
                             name='lstm1')
        net = recurrent.lstm(net,
                             n_units=124,
                             activation=tf.nn.relu,
                             return_seq=True,
                             name='lstm2')

        net = core.time_distributed(net, core.fully_connected, [128, 'relu'])
        net = core.time_distributed(net, core.fully_connected, [12])
        pose, uncertainty = tf.split(net, 2, axis=2)
        pose = tf.cast(pose, tf.float64)

        print("pose output shape")
        print(pose)

        #pose = core.fully_connected(net, activation=tf.nn.relu, n_units=128)
        #pose = core.fully_connected(net, n_units=6)
        #pose = tf.cast(pose, tf.float64)
        #print (pose)
        #print (tf.trainable_variables())

    return pose, uncertainty
def cnnLSTM_model():
    global model
    filter_size_conv1 = 11
    num_filters_conv1 = 5

    filter_size_conv2 = 6
    num_filters_conv2 = 10

    filter_size_conv3 = 5
    num_filters_conv3 = 5

    filter_size_conv4 = 2
    num_filters_conv4 = 2

    lstm_units = 500

    learning_rate = 1e-4
    y_true = tf.placeholder(tf.float32,
                            shape=[None, num_classes],
                            name='y_true')

    net = tflearn.input_data([None, 22, 64, 48, 1], name="input")
    net = time_distributed(
        net,
        conv_2d,
        args=[num_filters_conv1, filter_size_conv1, 1, 'same', 'tanh'])
    net = time_distributed(net, max_pool_2d, args=[2])
    net = time_distributed(
        net,
        conv_2d,
        args=[num_filters_conv2, filter_size_conv2, 1, 'same', 'tanh'])
    net = time_distributed(net, max_pool_2d, args=[2])
    net = time_distributed(
        net,
        conv_2d,
        args=[num_filters_conv3, filter_size_conv3, 1, 'same', 'tanh'])
    net = time_distributed(net, max_pool_2d, args=[2])
    net = time_distributed(net, flatten, args=['flat'])
    net = lstm(net, lstm_units)
    fc_layer = tflearn.fully_connected(net, num_classes, activation='softmax')
    loss = tflearn.objectives.categorical_crossentropy(fc_layer, y_true)
    network = regression(fc_layer,
                         optimizer='adam',
                         loss='categorical_crossentropy',
                         learning_rate=0.001)

    # Training
    model = tflearn.DNN(network,
                        tensorboard_verbose=0,
                        checkpoint_path='gestureCNNLSTM.tfl.ckpt')
Beispiel #3
0
cnnlstmmodel = conv_2d(cnnlstmmodel, 512, 2, activation='relu')
cnnlstmmodel = max_pool_2d(cnnlstmmodel, 2)

cnnlstmmodel = conv_2d(cnnlstmmodel, 256, 2, activation='relu')
cnnlstmmodel = max_pool_2d(cnnlstmmodel, 2)

cnnlstmmodel = conv_2d(cnnlstmmodel, 128, 2, activation='relu')
cnnlstmmodel = max_pool_2d(cnnlstmmodel, 2)

cnnlstmmodel = conv_2d(cnnlstmmodel, 64, 2, activation='relu')
cnnlstmmodel = max_pool_2d(cnnlstmmodel, 2)

cnnlstmmodel = conv_2d(cnnlstmmodel, 32, 2, activation='relu')
cnnlstmmodel = max_pool_2d(cnnlstmmodel, 2)

cnnlstmmodel = time_distributed(cnnlstmmodel, flatten, args=['flat'])
cnnlstmmodel = lstm(cnnlstmmodel, 1024)

cnnlstmmodel = fully_connected(cnnlstmmodel, 1000, activation='relu')
cnnlstmmodel = dropout(cnnlstmmodel, 0.7)

cnnlstmmodel = fully_connected(cnnlstmmodel, 10, activation='softmax')

cnnlstmmodel = regression(cnnlstmmodel,
                          optimizer='adam',
                          learning_rate=0.001,
                          loss='categorical_crossentropy',
                          name='regression')
model = tflearn.DNN(cnnlstmmodel, tensorboard_verbose=0)

# Load Saved Model
Beispiel #4
0
    elif predictedClass == 9:
        className = "Umur"

    cv2.putText(textImage, "Pedicted Class : " + className, (30, 30),
                cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)

    cv2.putText(textImage, "Confidence : " + str(confidence * 100) + '%',
                (30, 100), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)

    cv2.imshow("Statistics", textImage)


tf.reset_default_graph()
lstmmodel = input_data(shape=[None, 89, 100, 1], name='input')

lstmmodel = time_distributed(lstmmodel, dropout, args=[0.7])
lstmmodel = time_distributed(lstmmodel, flatten, args=['flat'])

lstmmodel = lstm(lstmmodel, 512)

lstmmodel = fully_connected(lstmmodel, 1000, activation='relu')
lstmmodel = dropout(lstmmodel, 0.7)

lstmmodel = fully_connected(lstmmodel, 10, activation='softmax')

lstmmodel = regression(lstmmodel,
                       optimizer='adam',
                       learning_rate=0.001,
                       loss='categorical_crossentropy',
                       name='regression')