import tensorflow as tf

from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.models import Sequential

from config import ImageSize


def get_model(imgsize: ImageSize, classes_count: int) -> keras.Model:
    """
    Return the new model to be trained.
    The model will contain the `data_augmentation` layer to reduce overfitting.
    """
    data_augmentation = keras.Sequential(
        [
            layers.experimental.preprocessing.RandomFlip("horizontal", input_shape=(imgsize.height, imgsize.width, 3)),
            layers.experimental.preprocessing.RandomRotation(0.1),
            layers.experimental.preprocessing.RandomZoom(0.1),
        ]
    )

    model = Sequential([
        data_augmentation,
        layers.experimental.preprocessing.Rescaling(1. / 255),
        layers.Conv2D(16, 3, padding='same', activation='relu'),
        layers.MaxPooling2D(),
        layers.Conv2D(32, 3, padding='same', activation='relu'),
        layers.MaxPooling2D(),
        layers.Conv2D(64, 3, padding='same', activation='relu'),
        layers.MaxPooling2D(),
        layers.Dropout(0.2),
        layers.Flatten(),
        layers.Dense(128, activation='relu'),
        layers.Dense(classes_count)
    ])

    model.compile(optimizer='adam',
                  loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
                  metrics=['accuracy'])
    return model

caf568e3f826e2ca49513ce626a33bb66806e192
<mask token>

<mask token>


def get_model(imgsize: ImageSize, classes_count: int) ->keras.Model:
    """
    Return the new model to be trained.
    The model will contain the `data_augmentation` layer to reduce overfitting.
    """
    data_augmentation = keras.Sequential([layers.experimental.preprocessing
        .RandomFlip('horizontal', input_shape=(imgsize.height, imgsize.
        width, 3)), layers.experimental.preprocessing.RandomRotation(0.1),
        layers.experimental.preprocessing.RandomZoom(0.1)])
    model = Sequential([data_augmentation, layers.experimental.
        preprocessing.Rescaling(1.0 / 255), layers.Conv2D(16, 3, padding=
        'same', activation='relu'), layers.MaxPooling2D(), layers.Conv2D(32,
        3, padding='same', activation='relu'), layers.MaxPooling2D(),
        layers.Conv2D(64, 3, padding='same', activation='relu'), layers.
        MaxPooling2D(), layers.Dropout(0.2), layers.Flatten(), layers.Dense
        (128, activation='relu'), layers.Dense(classes_count)])
    model.compile(optimizer='adam', loss=tf.keras.losses.
        SparseCategoricalCrossentropy(from_logits=True), metrics=['accuracy'])
    return model

import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.models import Sequential
from config import ImageSize


def get_model(imgsize: ImageSize, classes_count: int) ->keras.Model:
    """
    Return the new model to be trained.
    The model will contain the `data_augmentation` layer to reduce overfitting.
    """
    data_augmentation = keras.Sequential([layers.experimental.preprocessing
        .RandomFlip('horizontal', input_shape=(imgsize.height, imgsize.
        width, 3)), layers.experimental.preprocessing.RandomRotation(0.1),
        layers.experimental.preprocessing.RandomZoom(0.1)])
    model = Sequential([data_augmentation, layers.experimental.
        preprocessing.Rescaling(1.0 / 255), layers.Conv2D(16, 3, padding=
        'same', activation='relu'), layers.MaxPooling2D(), layers.Conv2D(32,
        3, padding='same', activation='relu'), layers.MaxPooling2D(),
        layers.Conv2D(64, 3, padding='same', activation='relu'), layers.
        MaxPooling2D(), layers.Dropout(0.2), layers.Flatten(), layers.Dense
        (128, activation='relu'), layers.Dense(classes_count)])
    model.compile(optimizer='adam', loss=tf.keras.losses.
        SparseCategoricalCrossentropy(from_logits=True), metrics=['accuracy'])
    return model

import tensorflow as tf

from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.models import Sequential

from config import ImageSize


def get_model(imgsize: ImageSize, classes_count: int) -> keras.Model:
    """
    Return the new model to be trained.
    The model will contain the `data_augmentation` layer to reduce overfitting.
    """
    data_augmentation = keras.Sequential(
        [
            layers.experimental.preprocessing.RandomFlip("horizontal", input_shape=(imgsize.height, imgsize.width, 3)),
            layers.experimental.preprocessing.RandomRotation(0.1),
            layers.experimental.preprocessing.RandomZoom(0.1),
        ]
    )

    model = Sequential([
        data_augmentation,
        layers.experimental.preprocessing.Rescaling(1. / 255),
        layers.Conv2D(16, 3, padding='same', activation='relu'),
        layers.MaxPooling2D(),
        layers.Conv2D(32, 3, padding='same', activation='relu'),
        layers.MaxPooling2D(),
        layers.Conv2D(64, 3, padding='same', activation='relu'),
        layers.MaxPooling2D(),
        layers.Dropout(0.2),
        layers.Flatten(),
        layers.Dense(128, activation='relu'),
        layers.Dense(classes_count)
    ])

    model.compile(optimizer='adam',
                  loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
                  metrics=['accuracy'])
    return model
