It is not possible to use numpy/opencv operations between forward()/backward() computations unless you implement those operations yourself using Torch Tensors (in a differentiable manner).
when you used .detach(), you are already disconnecting the graph and the further calculation with numpy/openCV has no effect on the weights of the Net.
Essentially, the loss in your code ( summed_loss_v=loss_v_from_pt+loss_v ) is interpreted as summed_loss_v=loss_v_from_pt+CONSTANT, hence it has no effect on optimization.