projet-long/utils/utils.py
milesial 5cd2a3b0b7 Restructure
Former-commit-id: beadb49b75ea79a3c0f95df589f64a8274419c5b
2021-08-16 06:08:09 +02:00

18 lines
531 B
Python

import matplotlib.pyplot as plt
def plot_img_and_mask(img, mask):
classes = mask.shape[0] if len(mask.shape) > 2 else 1
fig, ax = plt.subplots(1, classes + 1)
ax[0].set_title('Input image')
ax[0].imshow(img)
if classes > 1:
for i in range(classes):
ax[i + 1].set_title(f'Output mask (class {i + 1})')
ax[i + 1].imshow(mask[:, :, i])
else:
ax[1].set_title(f'Output mask')
ax[1].imshow(mask)
plt.xticks([]), plt.yticks([])
plt.show()