Flip an image or a set of heatmaps left-right Arguments: tensor {numpy.array or torch.tensor} -- [the input image or heatmaps] Keyword Arguments: is_label {bool} -- [denote wherever the input is an image or a set of heatmaps ] (default: {False})
(tensor, is_label=False)
| 304 | |
| 305 | |
| 306 | def flip(tensor, is_label=False): |
| 307 | """Flip an image or a set of heatmaps left-right |
| 308 | |
| 309 | Arguments: |
| 310 | tensor {numpy.array or torch.tensor} -- [the input image or heatmaps] |
| 311 | |
| 312 | Keyword Arguments: |
| 313 | is_label {bool} -- [denote wherever the input is an image or a set of heatmaps ] (default: {False}) |
| 314 | """ |
| 315 | if not torch.is_tensor(tensor): |
| 316 | tensor = torch.from_numpy(tensor) |
| 317 | |
| 318 | if is_label: |
| 319 | tensor = shuffle_lr(tensor).flip(tensor.ndimension() - 1) |
| 320 | else: |
| 321 | tensor = tensor.flip(tensor.ndimension() - 1) |
| 322 | |
| 323 | return tensor |
| 324 | |
| 325 | |
| 326 | def get_image(image_or_path): |
searching dependent graphs…