INNER CODE UNIT · Python

gray

patrickjohncyh/fashion-clip · fashion_clip/attention_map.py:50

    gray = np.ones_like(image) * 128

    image_crops = [image]
    masks = [np.ones_like(image)]

    horizontal_masks = generate_horizontal_masks(image_size, pixel_size)
    vertical_masks = generate_vertical_masks(image_size, pixel_size)
    for m in horizontal_masks+vertical_masks:
        m_bar = 1-m
        m_masked = image * m + gray * m_bar
        m_masked = m_masked.astype(np.uint8)
        image_crops.append(Image.fromarray(m_masked))
        masks.append(m)
    return image_crops, masks


def display_heatmap(image, text, heatmap):
    fig = plt.figure(figsize=(15, 30), facecolor='white')

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…