Diagnosing ear diseases from images of the tympanic membrane has emerged as a promising application for deep learning-based classification models. While several studies report high diagnostic accuracy, these models often struggle to generalize to external data that does not match the image characteristics of the training data. This study aims to evaluate methods for enhancing model generalizability. We trained artificial neural networks on tympanic membrane images from five datasets with a large heterogeneity between them. The datasets consisted of images from different countries, captured with different otoscope models, and with different image pre-processing applied at the source (e.g., colour normalization, cropping, and resolution). Artificial neural networks for binary (normal/abnormal) classification were trained on three datasets, and the models were evaluated on two. We explored several strategies to improve generalizability, including image pre-processing, data augmentation, transfer learning, and different network architectures. The effects of each investigated factor and their interactions were determined through a full factorial experimental design and linear mixed-effects model. Our best classification network achieved a mean accuracy of 83% (sensitivity 71%, specificity 91%) on external datasets. In contrast, the baseline trained without an optimized training method and using non-processed datasets yielded an accuracy of 53% (sensitivity 83%, specificity 34%). Our findings highlight how a better choice of network, training and augmentation strategies, and data verification improve model generalizability.