MCPcopy
hub / github.com/1adrianb/face-alignment / flip

Function flip

face_alignment/utils.py:306–323  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

304
305
306def 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
326def get_image(image_or_path):

Callers 3

test_flip_is_labelMethod · 0.85
test_flip_is_imageMethod · 0.85

Calls 1

shuffle_lrFunction · 0.85

Tested by 2

test_flip_is_labelMethod · 0.68
test_flip_is_imageMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…