As a malignant tumor with continuously rising incidence rates globally, skin cancer requires early and precise diagnosis to reduce the mortality rate. To address the challenges of insufficient model performance for clinical requirements and low diagnostic accuracy in minority categories of skin cancers, a model of an improved ResNet50 integrated with an ensemble classifier was proposed. Firstly, hair-induced noise was eliminated through grayscale black-hat threshold processing and Telea algorithm, and Synthetic Minority Over-sampling TEchnique (SMOTE) was used to balance class distribution. Secondly, the deep-level features were extracted using the ResNet50 model, with a soft attention module combining spatial and channel attention mechanisms introduced to focus on skin lesion regions. Finally, an ensemble classifier integrating random forest, eXtreme Gradient Boosting (XGBoost), Light Gradient Boosting Machine (LightGBM), K-Nearest Neighbor (K-NN), and Support Vector Machine (SVM) via soft voting was employed, and the proposed model was applied for early diagnosis of skin cancers. The results of three separate experiments on the HAM10000, ISIC2019 and ISIC2020 datasets indicate that the proposed model improves the accuracy to (98.33±0.03)%, (96.15±0.06)% and (99.19±0.02)%, respectively. Compared with current mainstream networks, the proposed model exhibits superior feature extraction and classification capabilities, and is helpful to improve early diagnostic effects.