Multi-inputs Convolutional Neural Network takes different number of images
You need to define what your training set is in this case. If a single input to your network is a pair of images $(a, b)$, and you only have 1500 examples of $b$, then you only have 1500 training examples.

If each image in $A$ can map to any arbitrary image in $B$, you can potentially re-use images in $B$ to create these input pairs. If that's not the case, which images in $A$ correspond to the image of interest in $B$?

Alternatively, if you don't want to (or it's not appropriate to) simply re-use the images, you could consider augmenting the smaller set by, for example, rotating, cropping, or otherwise manipulating the images in that dataset.

To re-initialize the generator, you would just execute this code again :

genX2 = generator.flow_from_directory(dir2, target_size = (img_height,img_width), class_mode = 'categorical', batch_size = batch_size, shuffle=False, seed=7)


When genX2.next() doesn't return anything. Alternatively, and more pythonically, you could use itertools.chain() to form a generator capable of returning the right number of observations:

n_times_through = math.ceil(4000/1500) 
genX2_new = itertools.chain(*([genX2] * n_times_through)