Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ayax537/convolutional-neural-network-cnn-for-image-classification
This Python script implements a Convolutional Neural Network (CNN) using TensorFlow and Keras for classifying images into different categories. The model is designed to process images of various densities, specifically for distinguishing between benign and malignant cases in a medical imaging context.
https://github.com/ayax537/convolutional-neural-network-cnn-for-image-classification
breast-cancer image-classification image-processing machine-learning
Last synced: 30 days ago
JSON representation
This Python script implements a Convolutional Neural Network (CNN) using TensorFlow and Keras for classifying images into different categories. The model is designed to process images of various densities, specifically for distinguishing between benign and malignant cases in a medical imaging context.
- Host: GitHub
- URL: https://github.com/ayax537/convolutional-neural-network-cnn-for-image-classification
- Owner: ayax537
- Created: 2024-11-11T08:52:17.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-11T08:53:28.000Z (about 2 months ago)
- Last Synced: 2024-11-11T09:38:57.924Z (about 2 months ago)
- Topics: breast-cancer, image-classification, image-processing, machine-learning
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Convolutional-Neural-Network-CNN-for-Image-Classification
# Description
This Python script implements a Convolutional Neural Network (CNN) using TensorFlow and Keras for classifying images into different categories. The model is designed to process images of various densities, specifically for distinguishing between benign and malignant cases in a medical imaging context.# Key Features
1. Data Preparation
Image Loading: The script utilizes TensorFlow's image_dataset_from_directory function to load training and testing datasets from specified directories. Images are resized to 224x224 pixels, and batches of 32 are created for efficient processing.
Class Names: The classes are defined as different density categories, including both benign and malignant labels.
2. CNN Architecture
Convolutional Layers: The model begins with convolutional layers that extract features from the input images. The architecture includes multiple convolutional layers with ReLU activation functions for non-linear transformations.
Pooling Layers: Max pooling layers are added to reduce the spatial dimensions of the feature maps, which helps in retaining essential features while decreasing the computational load.
Flattening: After feature extraction, the model flattens the 2D feature maps into a 1D array to prepare for the fully connected layers.
Fully Connected Layers: Dense layers are used to learn complex representations, with dropout layers to prevent overfitting.
Output Layer: The final layer uses a softmax activation function to classify the images into one of the eight defined categories.
3. Model Compilation and Training
The CNN is compiled with the Adam optimizer and sparse categorical crossentropy loss function, suitable for multi-class classification.
The model is trained on the training dataset for 15 epochs, with validation on the test dataset to monitor performance.
4. Model Evaluation
After training, the model is evaluated on the test dataset to assess its accuracy and performance metrics.
5. Prediction and Visualization
The script includes functionality to predict classifications on new images stored in a specified directory.
Results are visualized using Matplotlib, displaying the predicted class alongside the actual label for comparison.
# Conclusion
This script serves as a robust implementation of a CNN for image classification tasks, particularly in the medical imaging field. It showcases the use of deep learning techniques for feature extraction and classification, providing a framework that can be adapted for various image datasets and classification challenges. The model's architecture can be further fine-tuned to improve accuracy based on specific requirements or additional data.