-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.py
29 lines (24 loc) · 825 Bytes
/
show.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
import dataset
from torchvision import transforms
import matplotlib.pyplot as plt
path = '/home/lxg/codedata/ice/'
images, labels = dataset.read_clean(path, 'train_val.json')
train_set = dataset.train_cross(images, labels, 5)
train,label_train, test, label_test = train_set.getset(0)
print('train',train.shape, 'test', test.shape)
transform = transforms.Compose([
transforms.ToTensor() # simply typeas float and divide by 255
])
test_data = dataset.DataSet(test, label_test,
transform=transform, train=False)
img, lab = test_data[0]
img = img.numpy()
print('img:',img.shape, 'lab', lab)
for i in range(len(test_data)):
img,lab = test_data[i]
img = img.numpy()
f, (ax1,ax2) = plt.subplots(1,2)
ax1.imshow(img[0])
ax2.imshow(img[1])
f.suptitle(str(lab))
plt.show()