-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvisualization.py
37 lines (31 loc) · 1.47 KB
/
visualization.py
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
import matplotlib.pyplot as plt
import numpy as np
def display_predictions(training_images, preds, training_truths=[], submission_outputs=[], samples=5):
training_images = np.array(training_images)
preds = np.array(preds)
training_truths = np.array(training_truths)
submission_outputs = np.array(submission_outputs)
indices = np.random.choice(len(training_images), samples, replace=False)
dim = preds[0].shape[0]
columns = 3
if len(training_truths) == 0 and len(submission_outputs) == 0:
columns = 2
for i in range(samples):
ax1 = plt.subplot2grid((samples, columns), (i, 0))
ax1.imshow(training_images[indices][i])
ax1.axis('off')
ax1.set_title('Original Image')
ax2 = plt.subplot2grid((samples, columns), (i, 1))
ax2.imshow(preds[indices][i].reshape(dim, dim), cmap= 'Greys_r')
ax2.axis('off')
ax2.set_title('Predicted Mask')
if len(training_truths) != 0:
ax3 = plt.subplot2grid((samples, columns), (i, 2))
ax3.imshow(training_truths[indices][i].reshape(dim, dim), cmap= 'Greys_r')
ax3.axis('off')
ax3.set_title('Original Mask')
if len(submission_outputs) != 0:
ax3 = plt.subplot2grid((samples, columns), (i, 2))
ax3.imshow(submission_outputs[indices][i].reshape(dim, dim), cmap= 'Greys_r')
ax3.axis('off')
ax3.set_title('Submission Output')