I’m getting the same issue.
I load my script model and simply loop over images. The 2nd image results in this error every time (even when it’s the same image). Is there a way forward?
I triedthe example from @AndriyMulyar  and the error does not occure.