0

I have trained a custom CNN model for doing image classification upon two classes (Class A and B). I have used an image pre-processing method for edge detection before training. The code is given below:

def img_process(img):
  img_gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
  # Setting parameter values
  t_lower = 50  # Lower Threshold
  t_upper = 150  # Upper threshold
  aperture_size = 3

  # Applying the Canny Edge filter
  edge = (cv.Canny(np.uint8(img_gray), t_lower, t_upper))
  img = (cv.cvtColor(edge,cv.COLOR_GRAY2RGB)).astype(float)
  return img

After I did the trained model and evaluated the model on a test set. It did perform quite well (Almost 90+ accuracy on 30 test images). But when I did quantize the model in the following way:

quantize_model = tfmot.quantization.keras.quantize_model
q_aware_model = quantize_model(model)
q_aware_model.compile(loss='binary_crossentropy',
          optimizer=tf.keras.optimizers.Adam(learning_rate=0.001),
          metrics=['accuracy'])

When I tried to test the quantized model on the same test set, every image of my test set is classifying as Class B. How should I modify my quantized model to get accurate results?

0 Answers0