(raw_root_path, save_root_path)
| 67 | |
| 68 | # build CycleGAN trainSet B |
| 69 | def buildTrainB(raw_root_path, save_root_path): |
| 70 | BSize = 1000 |
| 71 | files_list = os.listdir(raw_root_path) |
| 72 | if not os.path.exists(save_root_path): |
| 73 | os.makedirs(save_root_path) |
| 74 | tb = np.arange(0, len(files_list)) |
| 75 | np.random.shuffle(tb) |
| 76 | start = time.time() |
| 77 | for i in range(0, BSize): |
| 78 | t0 = time.time() |
| 79 | imageName = files_list[tb[i]] |
| 80 | print('Begin {}/{}: {}'.format(i+1, BSize, imageName)) |
| 81 | imagePath = os.path.join(raw_root_path, imageName) |
| 82 | image = cv2.imread(imagePath, 0) |
| 83 | image = cv2.resize(image, (320, 320)) |
| 84 | savePath = os.path.join(save_root_path, imageName) |
| 85 | cv2.imwrite(savePath, image) |
| 86 | t1 = time.time() |
| 87 | print('End! Case time: {}'.format(t1-t0)) |
| 88 | end = time.time() |
| 89 | print('Finlly! Total time of build TrainB: {}'.format(end-start)) |
| 90 | |
| 91 | # resize all images in a directory |
| 92 | def resize_to_standard(path): |
nothing calls this directly
no outgoing calls
no test coverage detected