78 unmodified lines798081828384858687888978 unmodified linesFULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)unique_labels = np.unique(seg.astype("uint8"))ax = plt.subplot(grid_spec[1])plt.imshow(FULL_COLOR_MAP[unique_labels].astype(np.uint8), interpolation="nearest")ax.yaxis.tick_right()plt.yticks(range(len(unique_labels)), LABEL_NAMES[unique_labels])plt.xticks([], [])ax.tick_params(width=0.0, labelsize=25)return fig78 unmodified lines79808182838485868788899091929394959697989910078 unmodified linesFULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)# Limit unique_labels to be within the range of colormapunique_labels = np.unique(seg.astype("uint8"))unique_labels = unique_labels[unique_labels < len(colormap)]ax = plt.subplot(grid_spec[1])if len(unique_labels) > 0:plt.imshow(FULL_COLOR_MAP[unique_labels].astype(np.uint8), interpolation="nearest")ax.yaxis.tick_right()plt.yticks(range(len(unique_labels)), LABEL_NAMES[unique_labels])else:# Handle case when there are no unique labelsplt.imshow(np.zeros((1, 1, 3), dtype=np.uint8))ax.yaxis.tick_right()plt.yticks([], [])plt.xticks([], [])ax.tick_params(width=0.0, labelsize=25)return fig
app.py+14-3