I wonder if it’s a matter of paneling, because the paneling in M that cv2 gets is the pixel value, and the paneling in affine_grid is supposed to be proportional, so I deal with paneling in this way
The image shape is 448*448
M[0][2]=M[0][2]/448
M[1][2]=M[1][2]/448