- Marttis Ladev
- Raigo Leesment
- Mairon Mihklesoo
The primary motivation behind this project is to leverage automated image analysis to assist in diagnosing various lung diseases from chest X-ray images: Use machine learning methods to analyze chest X-rays and identify patterns indicative of different diseases and Develop a model capable of accurately classifying diseases and demonstrate
This repository contains all the necessary components for training, validating, and using a deep learning model for chest X-ray classification. Below is a structured explanation of the repository contents:
- Purpose: The central script for:
- Loading and preprocessing data
- Defining the model (using the ResNet50 base model)
- Training the model and saving checkpoints
- Loading a model from checkpoints
- Contents: Contains saved model weights and architecture for each epoch,
for example:
model_epoch_001.kerasmodel_epoch_002.keras
- Purpose: Enables resuming training from a specific point or loading a pre-trained model for inference.
- Contents: Images organized into class-specific subfolders:
Chest X_Ray Dataset/ ├── COVID19/ ├── NORMAL/ ├── PNEUMONIA/ └── TURBERCULOSIS/ - Purpose: Provides the input data for training and validation. Each subfolder represents a class.
- Contents: Description of the model architecture, including the ResNet50 base model and custom layers.
- Purpose: Used to document or recreate the model configuration.
- Purpose: A script to utilize the trained model for making predictions on new data.
- Key Features:
- Loads the trained model from a checkpoint
- Preprocesses input data (e.g., resizing and normalizing images)
- Generates predictions and visualizes results
- Run
main.ipynbor the equivalent training script to:- Preprocess the data
- Define the model
- Start training and save checkpoints
- Use the checkpoint directory (
model_checkpoints/) to load the model from a specific epoch. Theload_model_from_epochfunction facilitates this.
- Execute
ennustus.ipynbto load the trained model and make predictions on new datasets.
- Modify the architecture in
model_architect.jsonto add new layers or adjust the existing structure.
- Ensure that all images are correctly organized into subfolders within the dataset directory. Each subfolder name should correspond to its respective class label.
The model should be saved in the model_checkpoints directory, e.g., as a file model_epoch_955.keras.
Images should be in a folder. In ennustus.ipynb change images_folder to the path of your pictures. They should be in standard formats such
as .jpg or .png.
numpy, tensorflow, pillow
pip install tensorflow numpy pillow
The script: Loads the model and images. Normalizes the images. Makes predictions for each image (COVID-19, NORMAL, PNEUMONIA, TUBERCULOSIS) and shows the probabilities.
The predictions are printed in the terminal, showing the image name, predicted label, and the probability for the main prediction.