say I have
- a batch of images (batch_size, channel, height, width).
- a batch of landmarks (batch_size, n_landmarks, 2) (i.e. for each image, we have n_landmarks, each landmark is a (x,y) tuple of coordinates in the image)
For each image, I want to extract a patch of size (channel, patch_height, width_height) around each of the corresponding landmarks. The tensorflow equivalent is https://www.tensorflow.org/api_docs/python/tf/image/extract_glimpse
I have a numpy implementation here: https://gist.github.com/tdeboissiere/4e1ff2de0ceae5704bbaf06ceb9fd301
This patch extraction occurs several times within the pipeline so I’d like to do it on the GPU side. Is there any smart way to do it without having to write tons of loops ?