Crop images loaded on GPU using coordinates provided to eliminate host-device transfer

Hi guys,

Could you please give me a hand with the following. Thanks in advance.

Let’s say I create a batch of images (N video frames) and move them to GPU. Then, I have a list of coordinates that represent objects on the images that we earlier moved to GPU. I want to crop images using those coordinates (select only those regions) and then run only those areas through my network.

  1. Does anyone know a method that I could use to extract only those areas? I’ve tried using indexing [x1: x2, y1: y2, :] but it didn’t quite work. Probably I am doing something wrong.
  2. Could I combine them in a batch using .cat() or since they are already on GPU I could process them together?

Just a bit of background. I am building a system where multiple nets work one after another. Moving data back and forth (device-host) is expensive, so I thought I would move images to GPU only ones. I first detect objects of class A, then within this object A I want to find objects B and then classify them. So, the idea is to move images only ones and then just move coordinates back and forth.

Thanks a lot!

Regards,
Eugene