'memory overflow in custom tensorflow training loop

I've been working in tensorflow to load in images iteratively for each batch to preserve memory. This was done for a kaggle competition. I was wondering if anyone knew why my notebook was failing, I can't for the life of me determine where all my memory is going.

https://www.kaggle.com/kiernanmcguigan/efficientnet-for-individual-determination



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source