0

How can I implement this CNN model for text recognition from image, I would be very thankful for any help because I face into a big problem with generating train and test set.

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"])
  • Could you provide some clarification. Like what data are your working with? Is the above model failing for you in some way? How? I see categorical_crossentropy that makes we think you are working on the mnist data set or something similar. – Bobby Ocean Apr 27 '20 at 21:49
  • Can you clarify your question? Please see [ask], [help/on-topic]. – AMC Apr 27 '20 at 22:25
  • I am working with IAM dataset for word recognition! – yosra ammar Apr 30 '20 at 15:01

0 Answers0