I think you are doing wrong in this line auto img_tensor = torch::from_blob(img_float.data, { 1, 224, 224, 3 }).to(torch::kCUDA);. Because before this dimensions of your image are still [height, width, channels] then how you added an extra dimension in  { 1, 224, 224, 3 },  so first load your image by replacing it with only {224, 224, 3} and then before passing image to model just use this unsqueeze_(0). For further reference, you can see my code here 8.
You can also torchscript transform template also in c++.