Как я могу реализовать эту модель CNN для распознавания текста по изображению, я был бы очень благодарен за любую помощь, потому что я столкнулся с большой проблемой при создании поезда и тестового набора.
img = layers.Input(shape=img_shape) # Get image as an input and process it through some Convs
conv1 = layers.Conv2D(16, (3, 3), padding='same', activation='relu')(img)
mp1 = layers.MaxPooling2D(padding='same')(conv1)
conv2 = layers.Conv2D(32, (3, 3), padding='same', activation='relu')(mp1)
mp2 = layers.MaxPooling2D(padding='same')(conv2)
conv3 = layers.Conv2D(32, (3, 3), padding='same', activation='relu')(mp2)
bn = layers.BatchNormalization()(conv3)
mp3 = layers.MaxPooling2D(padding='same')(bn)
# Get flattened vector and make 5 branches from it. Each branch will predict one letter
flat = layers.Flatten()(mp3)
outs = []
for _ in range(5):
dens1 = layers.Dense(64, activation='relu')(flat)
drop = layers.Dropout(0.5)(dens1)
res = layers.Dense(num_symbols, activation='sigmoid')(drop)
outs.append(res)
# Compile model and return it
model = Model(img, outs)
model.compile(loss='categorical_crossentropy', optimizer='adam',metrics=["accuracy"])