Coder Social home page Coder Social logo

ml-bonesuppression's Introduction

Bone Suppression from Chest Radiographs

The project is a tool to build Bone Suppression model, written in tensorflow

CAM example image

Bone suppression is an autoencoder-like model for eliminating bone shadow from Chest X-ray images. The model require two types of dataset: normal and bone-suppression X-ray images. The target model can suppress bone shadow from Chest X-ray images, help Radiologists diagnose better lung related diseases. Although there are some softwares supporting bone suppression (ClearRead, CareStream), this project is a practical open source in computer vision and deep learning.

In this project you can

  1. Preprocessing data, including registration and augmentation.
  2. Train/test by following the quickstart. You can get a model with performance close to the paper.
  3. Visualize your training result with tensorboard

Requirements

The project requires Python>=3.5.

I have trained on an instance with 1 NVIDIA GTX 1080Ti (11GB VRAM) and it takes approximately 14 hours.

Configuration

  1. You can download the dataset here. This dataset includes 3 parts: JSRT dataset in png format, BSE_JSRT dataset in png format, and augmented dataset which can be trained directly.
  2. To register the dataset, make sure you set data_registration to true, and the input images are read from source_dir (JSRT) and target_dir (BSE_JSRT). The registered images will be saved to registered_output_dir into source and target subdirectories.
  3. To augment the dataset, make sure you set data_augmentation to true, the source_dir and target_dir will be used to augment. The total data after augmentation for source/target = augmentation_seed X total number of images in source_dir or target_dir. The augmented images will be saved to source and target subdirectories of augmented_output_dir with .png extension.
  1. source_folder and target_folder are folders to load training images.
  2. If you want to continue training from your last model, set use_trained_model to true and trained_model to your model path.
  3. output_model is where you save your model during training and output_log is where you save the tensorboard checkpoints.
  4. The other parameters is set following the published paper

Pretrained model

If you want to start testing without training from scratch, you can use the model I have trained. The model has loss value: 0.01409, MSE: 7.1687e-4, MS-SSIM: 0.01517

Quickstart

Note that currently this project can only be executed in Linux and macOS. You might run into some issues in Windows.

  1. Create & activate a new python3 virtualenv. (optional)
  2. Install dependencies by running pip install -r requirements.txt.
  3. Run python preprocessing.py to preprocess dataset. If you want to change your config path:
python preprocessing.py --config <config path>
  1. Run python train.py to train a new model. If you want to change your config path:
python train.py --config <config path>

During training, you can use Tensorboard to visualize the results:

tensorboard --logdir=<output_log in train.cfg>
  1. Run python test.py to evaluate your model on specific image. To change default parameters, you can use:
python test.py --model <model_path> --config <model config path> --input <image path> --output <output image path>

Acknowledgement

I would like to thank LoudeNOUGH for scratch training script and Hussam Habbreeh (حسام هب الريح) for sharing his experiences on this task.

Author

Chuong M. Huynh ([email protected])

License

MIT

ml-bonesuppression's People

Contributors

hmchuong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ml-bonesuppression's Issues

Error while running the pretrained model

I am running the command:
python3 test.py --model ./model/model.index --config ./config/train.cfg --input test.png --output output2.png

I am getting the following errors:

  1. File "/home/iplab/BoneSuppression/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1451, in _call_tf_sessionrun
    return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
    tensorflow.python.framework.errors_impl.NotFoundError: Tensor name "Variable" not found in checkpoint files ./model/model.index
    [[{{node save/RestoreV2}}]]
  2. Traceback (most recent call last):
    File "/home/iplab/BoneSuppression/lib/python3.8/site-packages/tensorflow/python/training/py_checkpoint_reader.py", line 69, in get_tensor
    return CheckpointReader.CheckpointReader_GetTensor(
    RuntimeError: _CHECKPOINTABLE_OBJECT_GRAPH not found in checkpoint file

Is there any solution to this issue?

Thanks & Regards,
Sourav Das

Are you model could be trained on GPU

Hi! I try to run train process, but it's too slow couse of CPU training.
I've found this line in reqiuirments: tensorflow-gpu==1.11.0.
And in readme:

I have trained on an instance with 1 NVIDIA GTX 1080Ti (11GB VRAM) and it takes approximately 14 hours.

Could you please share training code for GPU? Thanks in advance for your reply.

issue about packages not being compatible

hello, i cloned your repo in my computer, i created virtual environment and are you sure that these packages are compatible with each other? i have hard time to install all these packages

Model weights already trained

Hi,
I know its not a issue, but can you share your model weights (already trained)?
I'm trying a new approach and I would like something to compare.
Thanks!

Normal X-ray images only

Hello, can I use only normal X-ray images with a pre-trained model to obtain bone-suppressed images as the output?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.