Efficient Breast and Ovarian Cancer Classification via ViT-Based Preprocessing and Transfer Learning