I have a imbalanced dataset, for some classes, there are 3000 images, but for some classes, there are only 40 images for each class. So my idea is to train a model A on classes which have more images, while train a model B on classes which have less images.
Suppose two models perform well on each data, now how can I merge  these two models to predict all images?