Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lungdamagedetectioncli-1.0.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

lungdamagedetectioncli-1.0.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

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

Hashes for lungdamagedetectioncli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3ce2f9e9487c83fc7c70f9213067b90512d7b27eb932e52537e9447945600118
MD5 817c1a9215a85986e7fd95f214447560
BLAKE2b-256 a7585eea199a14fca2f19c3587adbece680d68e742168f1ff7e111dc26c07891

See more details on using hashes here.

File details

Details for the file lungdamagedetectioncli-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lungdamagedetectioncli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17a50cf5941fb013076e231ce693d2b19967a13a783d28429629acb2b93958bc
MD5 791ca35ed32e0048cf9eee2816d7da8e
BLAKE2b-256 8e794ed5eb6890d5eeec16ad60294b49006b1f5236879c9c102195717d9ac968

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page