SKINDEEP AI Skin Cancer Detection using Deep Learning BSSE Group: B4 Izma Najeeb Laiba Faisal Malik Shanial Tahir
Model training from scratch (when to use) We have a large, specific dataset that is significantly different from those used in pre-trained models. We need a custom architecture to address unique aspects of our problem that aren't covered by existing models. We have the computational resources and time to invest in training. 2
pre trained model (when to use) We have limited data for Wer specific task. We need to speed up development and reduce computational costs. The task is somewhat related to the one the model was originally trained on, allowing us to leverage learned features. 3
4 Model Training from Scratch Initialization : You start with an uninitialized model whose weights are randomly assigned. Data Requirement : Requires a large and diverse dataset specific to the problem at hand to effectively learn the task. Time and Resources : Training a model from scratch is computationally expensive and time-consuming, especially for complex models and large datasets. Customization : Offers complete control over the model architecture, making it possible to tailor the model to the specifics of the task. Risk of Overfitting : Without enough data or proper regularization techniques, the model might overfit to the training data, performing well on it but poorly on unseen data.
5 Using a Pre-trained Model Initialization : Begins with a model that has already been trained on a large dataset, typically on a general task such as image recognition or language understanding. Data Requirement : Can be effective with a smaller dataset for the specific task, as the model has already learned general features from the larger dataset it was initially trained on. Time and Resources : Significantly faster and less resource-intensive since the model has already learned a substantial amount of information. Fine-tuning or adapting the model to a specific task usually requires less computational power than training from scratch. Customization : While there is some flexibility through fine-tuning and adapting the model layers for the specific task, the core architecture and learned features are predetermined. Reduced Risk of Overfitting : Pre-trained models, especially when fine-tuned properly, are less likely to overfit on the target task due to their exposure to a more extensive and diverse initial training dataset.
Selecting an appropriate pre-trained model
7 VGG (Visual Geometry Group) VGG models are known for their simplicity and effectiveness. Variants such as VGG16 and VGG19 are widely used as feature extractors in transfer learning due to their architecture's straightforwardness. ResNet (Residual Network) ResNet models are known for their deep architecture with residual connections, which help address the vanishing gradient problem. Variants such as ResNet50, ResNet101, and ResNet152 are commonly used for various computer vision tasks, including skin cancer detection. Inception Inception models (also known as GoogLeNet ) are characterized by their inception modules, which allow the model to learn features at multiple scales. InceptionV3 and InceptionResNetV2 are popular variants used in transfer learning.
8 DenseNet DenseNet models are known for their densely connected layers, where each layer is connected to every other layer in a feed-forward fashion. DenseNet architectures offer advantages in parameter efficiency and feature reuse. Variants such as DenseNet121, DenseNet169, and DenseNet201 can be used for skin cancer detection. MobileNet MobileNet models are designed for efficient computation on mobile and embedded devices. These models offer a good balance between accuracy and computational efficiency, making them suitable for resource-constrained environments. Variants such as MobileNetV2 and MobileNetV3 can be utilized. EfficientNet EfficientNet models are known for automatically scaling up the model's depth, width, and resolution in a principled way to achieve better performance. EfficientNetB0 to EfficientNetB7 are available, with larger variants offering better accuracy at the cost of increased computational resources.
9 import tensorflow as tf from tensorflow.keras.applications import ResNet50 from tensorflow.keras.layers import Dense, GlobalAveragePooling2D from tensorflow.keras.models import Model # Load pre-trained ResNet50 model pretrained_model = ResNet50(weights=' imagenet ', include_top =False, input_shape =(224, 224, 3)) # Freeze pre-trained layers (optional) for layer in pretrained_model.layers : layer.trainable = False # Add new classification layers x = pretrained_model.output x = GlobalAveragePooling2D()(x) x = Dense(256, activation=' relu ')(x) predictions = Dense( num_classes , activation=' softmax ')(x) # num_classes is the number of classes in your dataset
10 # Create a new model with modified architecture model = Model(inputs= pretrained_model.input , outputs=predictions) # Compile the model model.compile (optimizer=' adam ', loss=' categorical_crossentropy ', metrics=['accuracy']) # Train the model (optional) model.fit ( train_data , train_labels , epochs=10, batch_size =32, validation_data =( val_data , val_labels )) # Make predictions predictions = model.predict ( test_data ) # Evaluate the model (optional) loss, accuracy = model.evaluate ( test_data , test_labels )