| 30 | |
| 31 | class ReshapePipeline(Pipeline): |
| 32 | def __init__( |
| 33 | self, device, batch_size, relative, use_wildcard, num_threads=3, device_id=0, num_gpus=1 |
| 34 | ): |
| 35 | super(ReshapePipeline, self).__init__( |
| 36 | batch_size, num_threads, device_id, seed=7865, exec_async=True, exec_pipelined=True |
| 37 | ) |
| 38 | self.device = device |
| 39 | self.input = ops.readers.Caffe( |
| 40 | path=caffe_db_folder, shard_id=device_id, num_shards=num_gpus |
| 41 | ) |
| 42 | self.decode = ops.decoders.Image(device="cpu", output_type=types.RGB) |
| 43 | W = 320 |
| 44 | H = 224 |
| 45 | self.resize = ops.Resize(device="cpu", resize_x=W, resize_y=H) |
| 46 | WC = -1 if use_wildcard else W * 3 |
| 47 | if relative: |
| 48 | rel_shape = (-1, 3) if use_wildcard else (1, 3) |
| 49 | self.reshape = ops.Reshape(device=device, rel_shape=rel_shape, layout="ab") |
| 50 | else: |
| 51 | self.reshape = ops.Reshape(device=device, shape=(H, WC), layout="ab") |
| 52 | |
| 53 | def define_graph(self): |
| 54 | jpegs, labels = self.input(name="Reader") |