[Solved] Loading trained CycleGan gives recursion error sometimes

I’m training the CycleGan on Colab from course v3 Github. Sometimes loading model gives me a “maximum recursion depth exceeded” error.

 from fastai.callbacks import SaveModelCallback

 learn = None
 cycle_gan = CycleGAN(3,3, gen_blocks=9)
 learn = Learner(data, cycle_gan, loss_func=CycleGanLoss(cycle_gan),
                 opt_func=partial(optim.Adam, betas=(0.5,0.99)),
                 callback_fns=[CycleGANTrainer] )

learn.callbacks =[SaveModelCallback(learn, every='epoch', monitor='accuracy', name='model2')]

Loading model again with code below if session is terminated. This works sometimes and sometimes not.
learn.load('/content/drive/My Drive/datasetv3/models/model2_44')

Tried increasing the recursion limit but didn’t help.

import sys
sys.setrecursionlimit(10000)

It seems it’s a known problem.

Solved by adding this to ImageTuple implementation as I saw it in the other topic.