def plot_images(images, img_shape,cls_true, cls_pred=None):
    assert len(images) == len(cls_true) == 42


    # Create figure with 7x6 sub-plots.
    fig, axes = plt.subplots(7, 6)
    fig.subplots_adjust(hspace=0.3, wspace=0.3)

    for i, ax in enumerate(axes.flat):
        # Plot image.
        # import cv2
        # cv2.imshow('image',images[0][0])
        # cv2.waitKey()
        ax.imshow(images[i][0], cmap='binary')

        # Show true and predicted classes.
        if cls_pred is None:
            xlabel = "True: {0}".format(cls_true[i])
        else:

            #to find corrrect class index
            cls = np.where(cls_true[i] == 1)[0][0]
            xlabel = "True: {0}, Pred: {1}".format(getAllCharacterFromIndex(cls), getAllCharacterFromIndex(cls_pred[i]))

        # Show the classes as the label on the x-axis.
        ax.set_xlabel(xlabel)

        # Remove ticks from the plot.
        ax.set_xticks([])
        ax.set_yticks([])

    # Ensure the plot is shown correctly with multiple plots
    # in a single Notebook cell.
    plt.show()
Beispiel #2
0
def get_class_name(index):
    return int(getAllCharacterFromIndex(index))