(file_name)
| 239 | |
| 240 | |
| 241 | def get_data(file_name): |
| 242 | if file_name.endswith('.lmdb'): |
| 243 | ds = LMDBSerializer.load(file_name, shuffle=True) |
| 244 | ds = ImageDecode(ds, index=0) |
| 245 | elif file_name.endswith('.zip'): |
| 246 | ds = ImageDataFromZIPFile(file_name, shuffle=True) |
| 247 | ds = ImageDecode(ds, index=0) |
| 248 | ds = RejectTooSmallImages(ds, index=0) |
| 249 | ds = CenterSquareResize(ds, index=0) |
| 250 | else: |
| 251 | raise ValueError("Unknown file format " + file_name) |
| 252 | augmentors = [imgaug.RandomCrop(128), |
| 253 | imgaug.Flip(horiz=True)] |
| 254 | ds = AugmentImageComponent(ds, augmentors, index=0, copy=True) |
| 255 | ds = MapData(ds, lambda x: [cv2.resize(x[0], (32, 32), interpolation=cv2.INTER_CUBIC), x[0]]) |
| 256 | ds = MultiProcessRunnerZMQ(ds, 3) |
| 257 | ds = BatchData(ds, BATCH_SIZE) |
| 258 | return ds |
| 259 | |
| 260 | |
| 261 | if __name__ == '__main__': |
no test coverage detected