I am working on a csv file, which in one column contains images (vectorized). Here is the csv file ~240MB.
I am trying to convert the Image string to a list of integers, reshape into matrix, flip, and the reshape it back to a list, then finally convert back in to a long string. But things didn't turn out to be what I expected. Below are my codes:
import pandas as pd
import numpy as np
df = pd.read_csv('training.csv')
img = df['Image'][0] # take the first row as example
img_int = np.fromstring(img, sep=' ') # img_int.shape --> (9216,), good.
img_matrix = img_int.reshape(96,96)
img_matrix_flipped = np.fliplr(img_matrix) # img_matrix_flipped.shape --> (96,96), good
img_matrix_flipped_vector = img_matrix_flipped.reshape(1, 9216) # img_matrix_flipped_vector.shape --> (1, 9216), good
img_matrix_flipped_vector_str = str(img_matrix_flipped_vector) # len(img_matrix_flipped_vector_str) --> 44, NOT GOOD!!!
I am confused about why the len(img_matrix_flipped_vector_str) is 44. Shouldn't the string contain all the 9216 integers in it? Please kindly help!