Skin cancer is regarded as the world's deadliest disease. Patients with incorrect diagnoses and substandard treatment have a very low chance of survival. However, if the disease is discovered sooner, the patient has a greater chance of survival and can be cured. Consequently, diagnosing and treating a patient in the earliest phases is difficult and complex. A system capable of autonomously diagnosing and detecting skin cancer at an earlier stage is required to address these issues. This study employed several deep learning models, including VGG16, VGG19, Xception, ResNet50, InceptionResNetV2, MobileNetV2, EfficientNetB7, and DenseNet121, to address this issue. The investigation was conducted using a dataset available to the public. Several preprocessing techniques were applied to the data before they were sent to the CNN model in order to improve the results. The first dataset was resized, and then it was tuned by enhancing the color, contrast, and sharpness of the images. Additional datasets were transmitted to multiple CNN models. With a score of 86.81%, EfficientNetB7 surpasses them. In addition, the EfficientNetB7 model was modified by adding layers and modifying hyperparameters to achieve more precise results. The proposed model's performance was evaluated based on its precision, fail classification rate, sensitivity, specificity, and F1-score. The proposed model achieved an accuracy of 90.60%, a miss classification rate of 9.39 percent, a sensitivity of 95.98%, a specificity of 85.4%, a precision of 86.38%, and a f1-score of 91.03%. Consequently, our proposed method outperformed existing CNN architectures and methodologies.