|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
from data_transformer import dataset
|
|
from data_loader import train_loader
|
|
|
|
|
|
def show_images(images, labels, num_images=5):
|
|
fig, axes = plt.subplots(1, num_images, figsize=(20, 5))
|
|
for i in range(num_images):
|
|
axes[i].imshow(np.transpose(images[i], (1, 2, 0)))
|
|
axes[i].set_title(labels[i])
|
|
axes[i].axis('off')
|
|
plt.show()
|
|
|
|
|
|
num_images_to_display = 5
|
|
sample_indices = np.random.choice(len(dataset), num_images_to_display, replace=False)
|
|
sample_images = [dataset[i][0] for i in sample_indices]
|
|
sample_labels = [dataset.classes[dataset[i][1]] for i in sample_indices]
|
|
|
|
|
|
|
|
|
|
from torchvision.utils import make_grid
|
|
|
|
def show_batch(dl):
|
|
for images, labels in dl:
|
|
fig, ax = plt.subplots(figsize=(16, 16))
|
|
ax.set_xticks([]); ax.set_yticks([])
|
|
ax.imshow(make_grid(images, nrow=12).permute(1, 2, 0))
|
|
break
|
|
|
|
|