# Import the necessary packages
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
from keras.models import Sequential

# A class for various CNN architectures
class CNNArchitecture:
    def __init__(self):
        pass

    @staticmethod
    def select(architecture, *args, **kargs):

        # Map strings to functions
        nets = {
            "MiniVGGNet": CNNArchitecture.MiniVGGNet,
            "MiniVGGNetCAM": CNNArchitecture.MiniVGGNetCAM
        }

        # Initialize architecture
        net = nets.get(architecture, None)

        # Check if a net has been requested
        if net is None:
            return None

        # If the net is named correctly, return the network architecture
        return net(*args, **kargs)

    @staticmethod
    def MiniVGGNet(imgrows, imgcols, numchannels, numclasses):
        # Initialize the model
        model = Sequential()

        # Define the first set of  CONV -> RELU -> CONV -> RELU -> POOL layers
        model.add(Convolution2D(32, 3, 3, input_shape=(imgrows, imgcols, numchannels), dim_ordering='tf'))
        model.add(Activation("relu"))
        model.add(Convolution2D(32, 3, 3))
        model.add(Activation("relu"))
        model.add(MaxPooling2D(pool_size=(3, 3)))

        # Add dropout
        model.add(Dropout(0.25))

        # Define the second set of CONV -> RELU -> CONV -> RELU -> POOL layers
        model.add(Convolution2D(64, 3, 3))
        model.add(Activation("relu"))
        model.add(Convolution2D(64, 3, 3))
        model.add(Activation("relu"))
        model.add(MaxPooling2D(pool_size=(2, 2)))

        # Add dropout
        model.add(Dropout(0.35))

        # Define FC -> RELU layers
        model.add(Flatten())
        model.add(Dense(512))
        model.add(Activation("relu"))

        # Add dropout
        model.add(Dropout(0.5))

        # Define the SoftMAX classifier
        model.add(Dense(numclasses))
        model.add(Activation("softmax"))

        # Return the network architecture
        return model

    @staticmethod
    def MiniVGGNetCAM():
        # Initialize the model
        model = Sequential()

        # Define the first set of  CONV -> RELU -> CONV -> RELU -> POOL layers
        model.add(Convolution2D(32, 3, 3, input_shape=(3, None, None), dim_ordering='th'))
        model.add(Activation("relu"))
        model.add(Convolution2D(32, 3, 3))
        model.add(Activation("relu"))
        model.add(MaxPooling2D(pool_size=(3, 3)))

        # Define the second set of CONV -> RELU -> CONV -> RELU -> POOL layers
        model.add(Convolution2D(64, 3, 3))
        model.add(Activation("relu"))
        model.add(Convolution2D(64, 3, 3))
        model.add(Activation("relu"))

        return model

@@ -452,67 +452,8 @@
 et,%0A
-            %22MiniVGGNetCAM%22: CNNArchitecture.MiniVGGNetCAM%0A
     
@@ -2015,712 +2015,4 @@
 del%0A
-%0A    @staticmethod%0A    def MiniVGGNetCAM():%0A        # Initialize the model%0A        model = Sequential()%0A%0A        # Define the first set of  CONV -%3E RELU -%3E CONV -%3E RELU -%3E POOL layers%0A        model.add(Convolution2D(32, 3, 3, input_shape=(3, None, None), dim_ordering='th'))%0A        model.add(Activation(%22relu%22))%0A        model.add(Convolution2D(32, 3, 3))%0A        model.add(Activation(%22relu%22))%0A        model.add(MaxPooling2D(pool_size=(3, 3)))%0A%0A        # Define the second set of CONV -%3E RELU -%3E CONV -%3E RELU -%3E POOL layers%0A        model.add(Convolution2D(64, 3, 3))%0A        model.add(Activation(%22relu%22))%0A        model.add(Convolution2D(64, 3, 3))%0A        model.add(Activation(%22relu%22))%0A%0A        return model%0A

remove obsolete net for cam