[dd6877]: / mediaug / visulize.py

Download this file

41 lines (36 with data), 859 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from IPython.display import display
from PIL import Image
from matplotlib import pyplot as plt
def show_image(img):
""" Display image in jupyter noteobok
Args:
img (np.array): The image
"""
display(Image.fromarray(img))
def plot_datapoint(dp):
""" plot a datapoint image and mask side by side
Args:
dp (Datapoint): datapoint
"""
plt.figure(figsize=(15,15))
plt.subplot(121)
plt.imshow(dp.img)
plt.axis('off')
plt.subplot(122)
plt.imshow(dp.mask)
plt.axis('off')
plt.show()
def plot_img_and_mask(img, mask):
""" plot image next to mask
Args:
img (np.array): image
mask (np.array): mask
"""
plt.figure(figsize=(15,15))
plt.subplot(121)
plt.imshow(img)
plt.axis('off')
plt.subplot(122)
plt.imshow(mask)
plt.axis('off')
plt.show()