Example #1
0
def apply_google_net(x):
    mean_values = np.array([104, 117, 123]).reshape((3, 1, 1))
    # Convert RGB to BGR
    xx = x[:, ::-1, :, :] * 255.0
    xx = xx - mean_values[np.newaxis, :, :, :].astype('float32')

    net = create_theano_expressions(inputs=('data', xx))
    pre_softmax = net[0]['loss3/classifier']

    return pre_softmax.flatten(2)
Example #2
0
def apply_vgg(x):
    from sklearn_theano.feature_extraction.caffe.vgg import create_theano_expressions
    mean_values = np.array([104, 117, 123]).reshape((3, 1, 1))
    # Convert RGB to BGR
    xx = x[:, ::-1, :, :] * 255.0
    xx = xx - mean_values[np.newaxis, :, :, :].astype('float32')

    net = create_theano_expressions(inputs=('data', xx))
    pre_softmax = net[0]['prob']

    return pre_softmax.flatten(2)