(interpreter, test_gen)
return accuracy, end - start
This is dog slow on an Intel machine. Use an Arm machine or edge tpu.
    Ref: https://stackoverflow.com/questions/54093424/why-is-tensorflow-lite-slower-than-tensorflow-on-desktop
This is dog slow on an Intel machine. Use an Arm machine or edge tpu.
    Ref: https://stackoverflow.com/questions/54093424/why-is-tensorflow-lite-slower-than-tensorflow-on-desktop
This is dog slow on an Intel machine . Use an Arm machine or edge tpu . Ref : https : // stackoverflow . com / questions / 54093424 / why - is - tensorflow - lite - slower - than - tensorflow - on - desktop
def evaluate_model(interpreter, test_gen):
    """
    This is dog slow on an Intel machine. Use an Arm machine or edge tpu.
    Ref: https://stackoverflow.com/questions/54093424/why-is-tensorflow-lite-slower-than-tensorflow-on-desktop
    """
    input_details = interpreter.get_input_details()
    input_index = input_details[0]['index']
    input_shape = input_details[0]['shape']
    input_size = tuple(input_shape[1:3])

    output_index = interpreter.get_output_details()[0]['index']
    
    accurate_count = 0
    num_images = 0
    start = time.time()

    for test_image, test_label in test_gen:
        img = cv2.imread(test_image) # read as np.uint8

        # Pre-processing: resize, add batch dimension to match with
        # the model's input data format.
        img = cv2.resize(img, input_size)
        img = np.expand_dims(img, axis=0)
        interpreter.set_tensor(input_index, img)

        # Run inference.
        interpreter.invoke()

        # Post-processing: remove batch dimension and find the digit with highest
        # probability.
        output = interpreter.tensor(output_index)
        class_id = np.argmax(output()[0])
        prediction = LABEL_MAP[class_id]

        # Compare prediction results with ground truth labels to calculate accuracy.
        if prediction == test_label:
            accurate_count += 1

        num_images += 1

        logger.debug('image: {} | ground truth: {} | prediction: {}'
            .format(path.basename(test_image), test_label, prediction))

    end = time.time()
    
    accuracy = accurate_count * 1.0 / num_images

    return accuracy, end - start
def evaluate_model ( interpreter , test_gen ) : input_details = interpreter . get_input_details ( ) input_index = input_details [ 0 ] [ 'index' ] input_shape = input_details [ 0 ] [ 'shape' ] input_size = tuple ( input_shape [ 1 : 3 ] ) output_index = interpreter . get_output_details ( ) [ 0 ] [ 'index' ] accurate_count = 0 num_images = 0 start = time . time ( ) for test_image , test_label in test_gen : img = cv2 . imread ( test_image ) # read as np.uint8 # Pre-processing: resize, add batch dimension to match with # the model's input data format. img = cv2 . resize ( img , input_size ) img = np . expand_dims ( img , axis = 0 ) interpreter . set_tensor ( input_index , img ) # Run inference. interpreter . invoke ( ) # Post-processing: remove batch dimension and find the digit with highest # probability. output = interpreter . tensor ( output_index ) class_id = np . argmax ( output ( ) [ 0 ] ) prediction = LABEL_MAP [ class_id ] # Compare prediction results with ground truth labels to calculate accuracy. if prediction == test_label : accurate_count += 1 num_images += 1 logger . debug ( 'image: {} | ground truth: {} | prediction: {}' . format ( path . basename ( test_image ) , test_label , prediction ) ) end = time . time ( ) accuracy = accurate_count * 1.0 / num_images return accuracy , end - start