Skip to content

zhongqiu1245/visualization

 
 

Repository files navigation

visualization

a collection of visualization operation

Contents

Usage

1. Grid Attention Visualization

import numpy as np
from visualize_attention_map.visualize_attention_map_V2 import visulize_attention_ratio

img_path = 'test_data/test_image.jpg'
save_path = 'test_data/'
random_attention = np.random.randn(14, 14)

visulize_attention_ratio(img_path=img_path, save_path=save_path, attention_mask=random_attention, save_image=True,
                   save_original_image=True)
  • img_path: where the image you want to put an attention mask on.
  • save_path: where to save the image.
  • attention_mask: the attention mask with format numpy.ndarray, its shape is (H, W)
  • save_image=True: save the image with attention map or not, default: True.
  • save_original_image=True: save the original image, default: True

Just run this example to see the result: grid_attention_example.py

Or you can check Attention Map Visualization here for more details

2. Region Attention Visualization

from visualize_region_attention.region_attention_visualization import region_attention_visualization
import numpy as np

img_path = "test_data/test_image.jpg"
boxes = np.array([[14, 25, 100, 200], [56, 75, 245, 300]], dtype='int')
region_attention_visualization(img_path, boxes, box_attentions=[0.36, 0.64], attention_ratio=1.0)
  • img_path: the path of the original image
  • boxes: bounding box
  • box_attentions: the attention score of each bounding box
  • attention_ratio: a special param, if you set the attention_ratio larger, it will make the attention map look more shallow. Just try!

Just run this example to see the result: region_attention_example.py

Or you can check Region Attention Visualization here for more details

3. Draw Line Chart

About

a collection of visualization function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%