小编Moh*_*ham的帖子

Why does my Google Colab Session run out of ram?

I have several images in a folder and i am trying to turn each one into grayscale and save them into another folder

Google Colab session keeps crashing due to running out of ram and i have tried using del on every variable

here is my code

img_array = []

for filename in FileArray:
    img = cv2.imread('train/train/Img-'+filename)
    height, width, layers = img.shape
    size = (width, height)
    img_array.append(img)

    image = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

    cv2.imwrite('train/gray/Img-'+filename, image)
    del img
    del height
    del width
    del layers …
Run Code Online (Sandbox Code Playgroud)

python opencv out-of-memory google-colaboratory

2
推荐指数
1
解决办法
3307
查看次数