Exemple #1
0
    [
        [SliceChannels(0, 192), layers.Convolution((128, 3, 3), padding=1, name="conv_5_1"), layers.Relu()],
        [SliceChannels(192, 384), layers.Convolution((128, 3, 3), padding=1, name="conv_5_2"), layers.Relu()],
    ],
    layers.Concatenate(),
    layers.MaxPooling((3, 3), stride=(2, 2)),
    layers.Reshape(),
    layers.Relu(4096, name="dense_1") > layers.Dropout(0.5),
    layers.Relu(4096, name="dense_2") > layers.Dropout(0.5),
    layers.Softmax(1000, name="dense_3"),
)

if not os.path.exists(ALEXNET_WEIGHTS_FILE):
    download_file(
        url=("http://srv70.putdrive.com/putstorage/DownloadFileHash/" "F497B1D43A5A4A5QQWE2295998EWQS/alexnet.pickle"),
        filepath=ALEXNET_WEIGHTS_FILE,
        description="Downloading weights",
    )

storage.load(alexnet, ALEXNET_WEIGHTS_FILE)

dog_image = load_image(
    os.path.join(CURRENT_DIR, "images", "dog.jpg"), image_size=(256, 256), crop_size=(227, 227), use_bgr=False
)

# Disables dropout layer
with alexnet.disable_training_state():
    x = T.tensor4()
    predict = theano.function([x], alexnet.output(x))

output = predict(dog_image)
Exemple #2
0
    layers.MaxPooling((2, 2)),
    layers.Convolution((512, 3, 3), padding=1, name="conv5_1") > layers.Relu(),
    layers.Convolution((512, 3, 3), padding=1, name="conv5_2") > layers.Relu(),
    layers.Convolution((512, 3, 3), padding=1, name="conv5_3") > layers.Relu(),
    layers.Convolution((512, 3, 3), padding=1, name="conv5_4") > layers.Relu(),
    layers.MaxPooling((2, 2)),
    layers.Reshape(),
    layers.Relu(4096, name="dense_1") > layers.Dropout(0.5),
    layers.Relu(4096, name="dense_2") > layers.Dropout(0.5),
    layers.Softmax(1000, name="dense_3"),
)

if not os.path.exists(VGG19_WEIGHTS_FILE):
    download_file(
        url=("http://srv70.putdrive.com/putstorage/DownloadFileHash/" "F9A70DEA3A5A4A5QQWE2301487EWQS/vgg19.pickle"),
        filepath=VGG19_WEIGHTS_FILE,
        description="Downloading weights",
    )

storage.load(vgg19, VGG19_WEIGHTS_FILE)

dog_image = load_image(os.path.join(CURRENT_DIR, "images", "dog.jpg"), image_size=(256, 256), crop_size=(224, 224))

# Disables dropout layer
with vgg19.disable_training_state():
    x = T.tensor4()
    predict = theano.function([x], vgg19.output(x))

output = predict(dog_image)
print_top_n(output[0], n=5)
Exemple #3
0
    layers.MaxPooling((2, 2)),

    Fire(64, 256, 256, name='fire9'),
    layers.Dropout(0.5),

    layers.Convolution((1000, 1, 1), padding='valid', name='conv10'),
    layers.GlobalPooling(function=T.mean),
    layers.Reshape(),
    layers.Softmax(),
)

if not os.path.exists(SQUEEZENET_WEIGHTS_FILE):
    download_file(
        url=(
            "http://srv70.putdrive.com/putstorage/DownloadFileHash/"
            "6B0A15B43A5A4A5QQWE2304100EWQS/squeezenet.pickle"
        ),
        filepath=SQUEEZENET_WEIGHTS_FILE,
        description='Downloading weights'
    )

storage.load(squeezenet, SQUEEZENET_WEIGHTS_FILE)

monkey_image = load_image(
    os.path.join(CURRENT_DIR, 'images', 'titi-monkey.jpg'),
    image_size=(256, 256),
    crop_size=(224, 224))

# Disables dropout layer
with squeezenet.disable_training_state():
    x = T.tensor4()
    predict = theano.function([x], squeezenet.output(x))
Exemple #4
0
    layers.Convolution((512, 3, 3), padding=1, name='conv5_2') > layers.Relu(),
    layers.Convolution((512, 3, 3), padding=1, name='conv5_3') > layers.Relu(),
    layers.MaxPooling((2, 2)),

    layers.Reshape(),

    layers.Relu(4096, name='dense_1') > layers.Dropout(0.5),
    layers.Relu(4096, name='dense_2') > layers.Dropout(0.5),
    layers.Softmax(1000, name='dense_3'),
)

if not os.path.exists(VGG16_WEIGHTS_FILE):
    download_file(
        url=(
            "http://srv70.putdrive.com/putstorage/DownloadFileHash/"
            "5B7DCBF43A5A4A5QQWE2301430EWQS/vgg16.pickle"
        ),
        filepath=VGG16_WEIGHTS_FILE,
        description='Downloading weights'
    )

storage.load(vgg16, VGG16_WEIGHTS_FILE)

dog_image = load_image(os.path.join(CURRENT_DIR, 'images', 'dog.jpg'),
                       image_size=(256, 256),
                       crop_size=(224, 224))

# Disables dropout layer
with vgg16.disable_training_state():
    x = T.tensor4()
    predict = theano.function([x], vgg16.output(x))