I am ml begginer and now study image processing. So I was trying to convert images to vectors using opencv on google colab, but it was loading very slowly compared to my PC. Is this a specification on google colab? If you know anything about this, I would appreciate it if you could let me know. Thank you!
Code to load images from the drive
def get_file(path1, path2, files, img_arrays=[], labels=[]):
num = 1
ids = files["id"]
classes = files.class_num
for file in ids:
if num <= 1102:
print("{}/{}".format(num, len(df_image_id)))
img = cv2.imread(DATADIR_TRAIN+file)
img= cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
crop_img = CropLemon()(image=img)['image']
img_array = cv2.resize(crop_img, (224, 224))
img_arrays.append(img_array)
num += 1
elif num > 1102:
print("{}/{}".format(num, len(df_image_id)))
img = cv2.imread(DATADIR_TEST+file)
img= cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
crop_img = CropLemon()(image=img)['image']
img_array = cv2.resize(crop_img, (224, 224))
img_arrays.append(img_array)
num += 1
for label in classes:
labels.append(label)
return img_arrays, labels
img_arrays, labels = get_file(DATADIR_TRAIN, DATADIR_TEST, df)
I have alredy tried to mount drive and reset runtime