It seems as if the class_weights might only be calculated from a single batch?
If that’s the case, the weights might be quite off and you should try to grab at least a few batches to approximate the valid class distribution.