In order to extract the pixels values from the file, we need to know how to extract one pixel value.
which color domain is used? is it a color pixel rgb or bgr ? or grayscale ? or …?
In the mean time, the float values (that are between -1 and 1?) can be extracted using a whitespace separator. The idea would be to do something like this:
with open("Im_1.txt", "r") as fd:
    content = fd.readlines().strip()
    # each row is split into a list of string representing float numbers
    # then each string is converted to a float with map(float, ...)
    pixel_values = [map(float, row.split(" ")) for row in content]

Now, IF the image is grayscale, the list pixel_values and contains 28 rows of 28 elements, we obtain the tensor:
image = torch.tensor(pixel_values)