Ny.rint = in Pytorch?

Please can someone let me know what command in Pytorch equals ny.rint.
I need to import black and white images and turn their pixels into only black or white pixels without a gray scale. Can anyone help?


You can call .round() function on your tensor to achieve np.rint kind of result.

I read I can also binary the images. Would you know how that works?


You can divide your gray scale image array by 255.0 (if you have 8-bit image because for 8-bit image pixel intensities ranges from 0 to 255) (if you have n-bit image then this number would be 2**n - 1) and apply .round() function to get binary image.