| 359 | |
| 360 | |
| 361 | class TestData(data.Dataset): |
| 362 | def __init__(self, test_img_file, test_label, transform=None, img_size=(144, 288)): |
| 363 | test_image = [] |
| 364 | for i in range(len(test_img_file)): |
| 365 | img = Image.open(test_img_file[i]) |
| 366 | img = img.resize((img_size[0], img_size[1]), Image.ANTIALIAS) |
| 367 | pix_array = np.array(img) |
| 368 | test_image.append(pix_array) |
| 369 | test_image = np.array(test_image) |
| 370 | self.test_image = test_image |
| 371 | self.test_label = test_label |
| 372 | self.transform = transform |
| 373 | |
| 374 | def __getitem__(self, index): |
| 375 | img1, target1 = self.test_image[index], self.test_label[index] |
| 376 | img1 = self.transform(img1) |
| 377 | return img1, target1 |
| 378 | |
| 379 | def __len__(self): |
| 380 | return len(self.test_image) |
| 381 | |
| 382 | |
| 383 | def load_data(input_data_path): |