--- license: apache-2.0 base_model: - google/mobilenet_v2_1.0_224 pipeline_tag: image-classification --- # 🦠 Melanoma Detection Model ## 📄 Overview 🤖 **Model Name:** MDM-3 🧠 **Model Type:** Convolutional Neural Network (CNN) 📊 **Input:** 224x224 RGB images of skin lesions 🔢 **Output:** A binary classification (Melanoma or Not Melanoma) 🎯 **Purpose:** To identify and classify skin lesions as melanoma or non-melanoma with high accuracy ☁️ **Download:** Click [here](https://huggingface.co/lizardwine/Melanoma-003/resolve/main/Melanoma-003.keras) to download --- ## 📚 Description This model is designed to detect melanoma from skin lesion images. It processes input images of size 224x224 pixels and outputs a binary classification indicating whether the lesion is melanoma or not. The model is trained to differentiate between malignant melanoma and benign conditions. --- ## 🔍 Use Cases 1. **Medical Diagnosis:** 🏥 Assisting dermatologists in diagnosing melanoma from images. 2. **Skin Cancer Screening:** 🩺 Enhancing early detection efforts in large-scale skin cancer screening programs. 3. **Patient Monitoring:** 👩‍⚕️ Helping in monitoring patients with a history of melanoma or high risk. --- ## 📈 Performance 🔍 **Accuracy:** ~99% on the [Skin Cancer Dataset](https://www.kaggle.com/datasets/shashanks1202/skin-cancer-dataset) 🕒 **Latency:** Suitable for real-time analysis in clinical settings. --- ## 🛠️ Technical Details - **Based on:** [MobileNetV2](https://www.kaggle.com/models/google/mobilenet-v2) - **Architecture:** Convolutional Neural Network (CNN) - **Layers:** Convolutional layers, pooling layers, fully connected layers - **Activation Functions:** ReLU, Sigmoid --- ## 📥 Input Format - **Type:** RGB image - **Shape:** 224x224 pixels - **Range:** 0-1 (pixel intensity) --- ## 📤 Output Format - **Type:** Binary classification - **Shape:** Scalar value - **Range:** 0 (Not Melanoma), 1 (Melanoma) --- ## 🧩 Model Training - **Dataset:** [Skin Cancer Dataset](https://www.kaggle.com/datasets/shashanks1202/skin-cancer-dataset) 📚 - **First step:** - **Training Epochs:** 50 - **Batch Size:** 32 - **Optimizer:** Adam - **Learning rate:** 1e-5 - **Layers:** Only last layer - **Second step:** - **Training Epochs:** 5 - **Batch Size:** 32 - **Optimizer:** Adam - **Learning rate:** 1e-5 - **Layers:** All layers --- ## 💡 How to Use 1. **Preprocess the Image:** Resize and normalize the image to 224x224 pixels with pixel values between 0 and 1. 2. **Feed the Image:** Input the preprocessed image into the model. 3. **Interpret the Output:** Analyze the output to determine if the lesion is melanoma or not. ### Loading the Model To use the model, first, load it using your preferred framework. ```python import tensorflow as tf # Load the pre-trained model model = tf.keras.models.load_model('path/to/Melanoma-003.keras') ``` ### Preprocessing the Input Preprocess the input image to fit the model's requirements. ```python import numpy as np from tensorflow.keras.preprocessing import image def preprocess_image(img_path): # Load the image img = image.load_img(img_path, target_size=(224, 224)) # Convert to numpy array img_array = image.img_to_array(img) # Normalize the image img_array = img_array / 255.0 # Reshape to add batch dimension img_array = np.expand_dims(img_array, axis=0) return img_array # Example usage img_path = 'path/to/your/image.jpg' processed_image = preprocess_image(img_path) ``` ### Making Predictions Use the model to predict if the lesion is melanoma. ```python # Predict the class prediction = model.predict(processed_image) # Interpret the result if prediction[0] > 0.5: print('The lesion is classified as Melanoma.') else: print('The lesion is classified as Not Melanoma.') ``` ### Full Example Combining all steps into a single example. ```python import tensorflow as tf import numpy as np from tensorflow.keras.preprocessing import image # Load the pre-trained model model = tf.keras.models.load_model('path/to/MelanomaDetectionModel.h5') def preprocess_image(img_path): img = image.load_img(img_path, target_size=(224, 224)) img_array = image.img_to_array(img) img_array = img_array / 255.0 img_array = np.expand_dims(img_array, axis=0) return img_array img_path = 'path/to/your/image.jpg' processed_image = preprocess_image(img_path) prediction = model.predict(processed_image) if prediction[0] > 0.5: print('The lesion is classified as Melanoma.') else: print('The lesion is classified as Not Melanoma.') ``` --- ## ⚠️ Limitations - **Image Quality:** Performance may be affected by poor-quality or low-resolution images. - **Generalization:** Model performance may vary with images not represented in the training data. --- ## 👥 Contributors - **Developer:** Lizardwine (x@lizardwine.com) - **Organization:** lizardwine - **Date:** 05/09/2024 --- ## 📝 References - Skin Cancer Dataset: [Link](https://www.kaggle.com/datasets/shashanks1202/skin-cancer-dataset) - MobileNetV2: [Link](https://www.kaggle.com/models/google/mobilenet-v2) ---