I am trying to read multiple images using python 3 on google colab and local host. Unfortunately, the memory crashes at 25 images and exceed 12 GB RAM. Here is a snippet of my code after several trials.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib.image as img
from scipy.cluster.vq import kmeans, vq
from google.colab import drive
from PIL import Image
import cv2
import glob
import numpy as np
r = []
g = []
b = []
df=[]
files = glob.glob ("drive/MyDrive/rgb1/*.pg.jpg")
for file in files:
im = Image.open(file)
pix=list(im.getdata())
for pixel in pix:
r.append(pixel[0])
g.append(pixel[1])
b.append(pixel[2])
d = pd.DataFrame({'red':r, 'green':g, 'blue':b})
df.append(d)
im.close()