All available RAM was used in google colab while training a model of big data

Viewed 358

I am working on binary image classification of big number of 3 channeled 512*512 images. I used VGG16 for feature extraction for a generator built from imagedatagenerator. While training the feature extraction model on colab, the RAM usage increases until it crashes the session before it finished training. I tried changing batch size, taking 1 channeled images-graysclae-, and resizing images, but all failed. The code is:

train_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
        '/content/gdrive/MyDrive/Covid_data/Training Set',  
        target_size=(224, 224), 
        batch_size=batch_size,
        color_mode="grayscale",
        classes = ['covid','non-covid'],
        class_mode='binary')

The feature extraction code is:

SIZE = 224
VGG_model = VGG16(weights=None, include_top=False, input_shape=(SIZE, SIZE, 1))

for layer in VGG_model.layers:
    layer.trainable = False
feature_extractor=VGG_model.predict(train_generator)

Is there a way that I can increase or empty the RAM and the Disk till I finish training the model and stay allowed to use the features extracted later in the code?

Thank you very much.

0 Answers
Related