Hi,
Give that you use .cpu(), I guess you have a cuda Tensor?
Unfortunately, I don’t think opencv support gpu? So you will have to move the Tensor back to CPU to use it with opencv.
Note that the conversion to numpy itself is almost free as we share memory with the numpy array.
If you use operations that are available on pytorch, I would advise using pytorch’s gpu version of these ops to keep best performances !