How to use h5 file from DLS in nativ code in Keras, Python

I used Keras with TensorFlow in Python to developed CNN.
Now I started to use DLS for building the network and the training.
I developed in Python using Keras a piece of code to do the classification for new images.
I want to use the same code for the classification as it part of much bigger system.
I tried to replace the H5 file with the one I downloaded from DLS.
I get an error when trying to run my code now.
I assume that the problem is how I prepare the image to be classified.
I’m not sure how should I prepare it now and I’m not sure that this is really the problem.

I’ll appreciate very much any suggestions and any help.

My relevant code:
# I’m not using normalize so I think I don’t need the next line. Is it correct?
#partImg = partImg.astype(“float”) / 255.0

     # check to see if we should flatten the image and add a batch
     # dimension
     #**_if needed to be flatten I use these two lines_**
         #partImg = partImg.flatten()
         #partImg = partImg.reshape((1, partImg.shape[0]))

     # **_otherwise, I use this line_**
         partImg = partImg.reshape((1, partImg.shape[0], partImg.shape[1], partImg.shape[2]))
 
     # make a prediction on the image
     preds = model.predict(partImg)

The error I get:
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your InputLayer call to the Keras 2 API: InputLayer(dtype="float32", sparse=False, name="Input_0", batch_input_shape=[None, 3, ...)
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215875", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=256, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215876", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=256, activation="linear", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_91203", trainable=True, padding="valid", data_format="channels_first", pool_size=[2, 2], strides=[2, 2])
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215877", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=128, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215878", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=128, activation="linear", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your BatchNormalization call to the Keras 2 API: BatchNormalization(name="batchnormalization_76302", trainable=True, axis=-1, epsilon=0.001, beta_regularizer=None, gamma_regularizer=None, momentum=0.99)
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_91204", trainable=True, padding="valid", data_format="channels_first", pool_size=[2, 2], strides=[2, 2])
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215879", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=64, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215880", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=64, activation="linear", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215881", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=64, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215882", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=64, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_91205", trainable=True, padding="valid", data_format="channels_first", pool_size=[2, 2], strides=[2, 2])
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215883", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=32, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215884", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=32, activation="linear", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your BatchNormalization call to the Keras 2 API: BatchNormalization(name="batchnormalization_76303", trainable=True, axis=-1, epsilon=0.001, beta_regularizer=None, gamma_regularizer=None, momentum=0.99)
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215885", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=32, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215886", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=32, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_91206", trainable=True, padding="valid", data_format="channels_first", pool_size=[2, 2], strides=[2, 2])
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215887", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=32, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215888", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=32, activation="linear", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215889", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=32, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(trainable=True, padding="same", strides=[1, 1], use_bias=True, bias_constraint=None, bias_regularizer=None, name="convolution2d_215890", data_format="channels_first", kernel_regularizer=None, activity_regularizer=None, kernel_size=(2, 2), filters=32, activation="relu", kernel_constraint=None, kernel_initializer="glorot_uniform")
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your MaxPooling2D call to the Keras 2 API: MaxPooling2D(name="maxpooling2d_91207", trainable=True, padding="valid", data_format="channels_first", pool_size=[2, 2], strides=[2, 2])
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Dense call to the Keras 2 API: Dense(kernel_regularizer=None, trainable=True, activity_regularizer=None, use_bias=True, bias_regularizer=None, name="dense_92998", activation="linear", bias_constraint=None, kernel_constraint=None, kernel_initializer="glorot_uniform", units=2048, input_dim=288)
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Dense call to the Keras 2 API: Dense(kernel_regularizer=None, trainable=True, activity_regularizer=None, use_bias=True, bias_regularizer=None, name="dense_92999", activation="linear", bias_constraint=None, kernel_constraint=None, kernel_initializer="glorot_uniform", units=1024, input_dim=2048)
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your BatchNormalization call to the Keras 2 API: BatchNormalization(name="batchnormalization_76304", trainable=True, axis=-1, epsilon=0.001, beta_regularizer=None, gamma_regularizer=None, momentum=0.99)
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Dropout call to the Keras 2 API: Dropout(name="dropout_42474", trainable=True, rate=0.4)
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Dense call to the Keras 2 API: Dense(kernel_regularizer=None, trainable=True, activity_regularizer=None, use_bias=True, bias_regularizer=None, name="dense_93000", activation="linear", bias_constraint=None, kernel_constraint=None, kernel_initializer="glorot_uniform", units=1024, input_dim=1024)
return cls(**config)
/usr/lib64/python3.4/site-packages/keras/engine/base_layer.py:1109: UserWarning: Update your Dense call to the Keras 2 API: Dense(kernel_regularizer=None, trainable=True, activity_regularizer=None, use_bias=True, bias_regularizer=None, name="dense_93001", activation="softmax", bias_constraint=None, kernel_constraint=None, kernel_initializer="glorot_uniform", units=3, input_dim=1024)
return cls(**config)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in ()
69
70 # make a prediction on the image
—> 71 preds = model.predict(partImg)
72
73 # find the class label index with the largest corresponding

Hi this error is because DLS uses older version of Keras API and you have installed updated version on your system.

Regards
Rajat