at::Tensor convert(const dlib::array2d<dlib::rgb_pixel> & img)
{
const auto height = img.nr();
const auto width = img.nc();
auto tensor = at::zeros({1, 3, height, width});
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
tensor[0][0][y][x] = img[y][x].blue;
tensor[0][1][y][x] = img[y][x].green;
tensor[0][2][y][x] = img[y][x].red;
}
}
return tensor;
}