79290464

Date: 2024-12-18 08:47:57
Score: 0.5
Natty:
Report link
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;
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Ulrich Von Rekkenin