def make_activations_model(model, idx_layers_to_show=None, verbose=True):
    """Accepts a Keras image convolution model and exports a new model,
    with just the intermediate activations to plot with plot_activations()."""
    import keras
    import matplotlib.pyplot as plt
    from keras import models
    import numpy as np
    if idx_layers_to_show == None:
        layers_to_show = []
        for l, layer in enumerate(model.layers):
            check_type = type(layer)
            if check_type in [keras.layers.convolutional.Conv2D, keras.
                layers.pooling.MaxPooling2D]:
                layers_to_show.append(layer)
        layer_outputs = [layer.output for layer in layers_to_show]
    else:
        check_dims = np.shape(idx_layers_to_show)
        if check_dims == 2:
            idx_start = idx_layers_to_show[0]
            idx_end = idx_layers_to_show[1]
            layer_outputs = [layer.output for layer in model.layers[
                idx_start:idx_end]]
        elif check_dims == 1:
            layer_outputs = [layer.output for layer in model.layers[
                idx_layers_to_show]]
    activation_model = models.Model(inputs=model.input, outputs=layer_outputs)
    if verbose == True:
        print(activation_model.summary())
    return activation_model
