Loading image from file. Args: color_type (str): Flags specifying the color type of a loaded image, candidates are 'color', 'grayscale' and 'unchanged'. channel_order (str): Order of channel, candidates are 'bgr' and 'rgb'.
| 181 | |
| 182 | |
| 183 | class LoadImageFromFile: |
| 184 | """Loading image from file. |
| 185 | |
| 186 | Args: |
| 187 | color_type (str): Flags specifying the color type of a loaded image, |
| 188 | candidates are 'color', 'grayscale' and 'unchanged'. |
| 189 | channel_order (str): Order of channel, candidates are 'bgr' and 'rgb'. |
| 190 | """ |
| 191 | |
| 192 | def __init__(self, |
| 193 | to_float32=False, |
| 194 | color_type='color', |
| 195 | channel_order='rgb'): |
| 196 | self.to_float32 = to_float32 |
| 197 | self.color_type = color_type |
| 198 | self.channel_order = channel_order |
| 199 | |
| 200 | def __call__(self, results): |
| 201 | """Loading image from file.""" |
| 202 | image_file = results['image_file'] |
| 203 | img = PetrelHelper.imread(image_file, cv2.IMREAD_COLOR) |
| 204 | |
| 205 | img = img[:, :, ::-1] # BGR -> RGB |
| 206 | if img is None: |
| 207 | raise ValueError('Fail to read {}'.format(image_file)) |
| 208 | |
| 209 | results['image'] = img |
| 210 | return results |
| 211 | |
| 212 | |
| 213 | class TopDownRandomFlip: |