-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error while using the saved model #9
Comments
Regarding this, I want to convert but I am not getting what are you doing here Thank you! |
the trained model is a compiled and complete network with weights, you can just use |
Thank you so much for replying back.
|
See line 53, line 142 in CRNN_with_STN.py |
Actually yes, As per my search Keras has problem loading the model while there are custom layers. |
@sbillburg Can you please let me know your idea toward this error?
|
when I load a ctc model I have this problem: ValueError: Unknown loss function: pad each output label to maximum text lengthtrain_padded_txt = pad_sequences(training_txt, maxlen=max_label_len, padding='post', value = len(char_list)) input with shape of height=32 and width=128input with shape of height=32 and width=128inputs = Input(shape=(32,128,1)) convolution layer with kernel size (3,3)conv_1 = Conv2D(64, (3,3), activation = 'relu', padding='same')(inputs) poolig layer with kernel size (2,2)pool_1 = MaxPool2D(pool_size=(2, 2), strides=2)(conv_1) conv_2 = Conv2D(128, (3,3), activation = 'relu', padding='same')(pool_1) conv_3 = Conv2D(256, (3,3), activation = 'relu', padding='same')(pool_2) conv_4 = Conv2D(256, (3,3), activation = 'relu', padding='same')(conv_3) poolig layer with kernel size (2,1)pool_4 = MaxPool2D(pool_size=(2, 1))(conv_4) conv_5 = Conv2D(512, (3,3), activation = 'relu', padding='same')(pool_4) Batch normalization layerbatch_norm_5 = BatchNormalization()(conv_5) conv_6 = Conv2D(512, (3,3), activation = 'relu', padding='same')(batch_norm_5) conv_7 = Conv2D(512, (2,2), activation = 'relu')(pool_6) squeezed = Lambda(lambda x: K.squeeze(x, 1))(conv_7) bidirectional LSTM layers with units=128blstm_1 = Bidirectional(LSTM(128, return_sequences=True, dropout = 0.2))(squeezed) outputs = Dense(len(char_list)+1, activation = 'softmax')(blstm_2) model to be used at test timeact_model = Model(inputs, outputs) act_model.summary() #the CTC loss fnction is to predict the output text, it is very helpfull for the def ctc_lambda_func(args):
loss_out = Lambda(ctc_lambda_func, output_shape=(1,), name='ctc')([outputs, labels, input_length, label_length]) #model to be used at training time #train the model model.compile(loss={'ctc': lambda y_true, y_pred: y_pred}, optimizer = 'adam') callbacks_list = [checkpoint] valid_img = np.array(valid_img) model.fit(x=[training_img, train_padded_txt, train_input_length, train_label_length], model.save(filepath) #test the model load the saved best model weightsnew_model = load_model(filepath) |
When I want to use the saved mode to get prediction based on that, it raises
Do you have any idea of this?
this is my piece of code:
I gave custom_object backend because firstly it did not recognize backend.
now it raising error for loss, and I tried to assign loss in the custom object but it did not work.or maybe I have to try something else.
can you please have a look on this.
Thank you
The text was updated successfully, but these errors were encountered: