CLI application for training and inferring lung injury detection model
Project description
LUNG INJURY DETECTION CLI APP
This repository provides source code of CLI app for training and inferring lung injury detection model. The model is based on U-Net architecture implemented with pytorch framework for python.
INSTALLATION
The project depends on python ==3.10.*
Install from PyPI:
pip install LungDamageDetectionCLI
Install from repo:
git clone <repo-name> && cd <project-dir>
pdm install
DEVELOPMENT AND USE
Run CLI app from project dir
pdm run ldd-cli SUBCOMMAND
This app supports these subcommands:
- train - run model training
- test - run model test
- inference - detect injuries
You may copy .env.example and rename it into .env
Environment Variables
PATH_TO_DATA= # directory containing dataset
DCM_DIR= # directory inside PATH_TO_DATA containing dcm files
PNG_DIR= # directory inside PATH_TO_DATA containing png files
TRAIN_SET= # number of images for model training
TEST_SET= # number of images for model test
VAL_SET= # number of images for model validation
EPOCHS= # number of training epochs
LR= # learning rate
BATCH_SIZE= # size of batch
IMG_SIZE=512 # width and height of images in dataset
BACKBONE=resnet101 # name of backbone model
SAVE_PATH= # path of trained model state dict
OUT_PATH= # directory to save inference results
INPUT_PATH= # dcm file or directory of dcm files for model inference
USE_AUGMENTATION=false # dataset is loaded with augmentation if true
SEED=5 # seed for numpy.random.seed
or pass desired values through command line args (names of args are case insensitive).
Supported backbone names:
- resnet18
- resnet34
- resnet50
- resnet101
- resnet152
- vgg16
- vgg19
- densenet121
- densenet161
- densenet169
- densenet201
All code is placed in src directory.
To train model place .dcm files of CT of lungs in PATH_TO_DATA/DCM_DIR and .png masks in PATH_TO_DATA/PNG_DIR then set TRAIN_SET, VAL_SET and TEST_SET variables according to your dataset size. App saves state dict of model every epoch. If SAVE_PATH file exists model will be loaded using it when the app is restarted.
If USE_AUGMENTATION is true some images will be rotated, cropped and flipped.
After model test trained model metrics are printed.
Metrics
- precision
- recall
- f1 score
- jaccard coefficient
- dice coefficient
To inference model you have to provide path of dcm file or path of directory with several dcm files into INPUT_PATH.
Result png files are placed in OUTPUT_PATH. Png files have same name as dcms.
LICENSE
Lung injury detection CLI app is MIT licensed
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lungdamagedetectioncli-1.0.0.tar.gz
.
File metadata
- Download URL: lungdamagedetectioncli-1.0.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.4 CPython/3.9.13 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ce2f9e9487c83fc7c70f9213067b90512d7b27eb932e52537e9447945600118 |
|
MD5 | 817c1a9215a85986e7fd95f214447560 |
|
BLAKE2b-256 | a7585eea199a14fca2f19c3587adbece680d68e742168f1ff7e111dc26c07891 |
File details
Details for the file lungdamagedetectioncli-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: lungdamagedetectioncli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.4 CPython/3.9.13 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17a50cf5941fb013076e231ce693d2b19967a13a783d28429629acb2b93958bc |
|
MD5 | 791ca35ed32e0048cf9eee2816d7da8e |
|
BLAKE2b-256 | 8e794ed5eb6890d5eeec16ad60294b49006b1f5236879c9c102195717d9ac968 |