Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_image_saliency_plot(image_saliency_results, cols: int = 2, figsize: tuple = None, display=True, save_path=False):
rows = math.ceil(len(image_saliency_results) / cols)
figsize = figsize or (8, 3 * rows)
figure = plt.figure(figsize=figsize)
for i, r in enumerate(image_saliency_results):
ax = figure.add_subplot(rows, cols, i + 1)
ax.set_xticks([])
ax.set_yticks([])
ax.set_title(r.title, fontdict={'fontsize': 18})
saliency_upsampled = skimage.transform.resize(r.saliency,
(r.raw_image.height, r.raw_image.width),
mode='reflect')
show_image(r.raw_image, img2=saliency_upsampled, alpha2=r.saliency_alpha, cmap2=r.saliency_cmap, ax=ax)
if display:
figure.show()
figure.waitforbuttonpress()
if save_path:
figure.savefig(save_path)
return figure