Pass raw images without ToTensor()

Hello I want to pass raw images(0-255) to my CNN.

I am not using ToTensor().

img1 = self.loader(os.path.join(self.root1, path1))
img1 = torch.from_numpy(np.asarray(img1)).float()

I got a warning.
UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program.

What it mean, does it will affect CNN in any manner?

No, it shouldn’t affect the model training as long as you don’t try to write to the underlying numpy array.
You could create a copy of the numpy array to get rid of this warning, since from_numpy will share the same data between the tensor and np.array.

I did this

img1 = self.loader(os.path.join(self.root1, path1))
img1 = np.asarray(img1)
img1 = torch.from_numpy((img1)).float()

Still got the warning

np.asarray is also using the reference, if no copy is needed.
From the docs:

Array interpretation of a . No copy is performed if the input is already an ndarray with matching dtype and order. If a is a subclass of ndarray, a base class ndarray is returned.

img1 = self.loader(os.path.join(self.root1, path1))
img1 = torch.from_numpy(1.0 * np.asarray(img1)).float()