1. 图片保存到当前工作目录:
2. 运行代码
import cv2
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
def visulize_spatial_attention(img_path, attention_mask, ratio=1, cmap="jet"):
"""
img_path: image file path to load
save_path: image file path to save
attention_mask: 2-D attention map with np.array type, e.g, (h, w) or (w, h)
ratio: scaling factor to scale the output h and w
cmap: attention style, default: "jet"
"""
print