Giter Club home page Giter Club logo

rvsc-medical-image-segmentation's Introduction

If you are familiar with Chinese, I recommend you to read 中文版README.

Preparation

Create a working directory and pull the code.

mkdir ws
cd ws
git clone https://github.com/omigeft/RVSC-Medical-Image-Segmentation.git src

The code was tested on Ubuntu 22.04, RTX 4090 * 1, CUDA 12.1, Python=3.10, torch=2.1.2, torchvision=0.16.2. Other similar versions should also work.

To install other required packages, run:

pip install -r requirements.txt

To visualize the training process, you need to register an account on Weights & Biases. Then run the following command and follow the instructions to log in.

wandb login

Data Preprocess

Download the datasets from https://rvsc.projets.litislab.fr/. Extract them to the ws directory and manually organize dataset files into the structure as follows:

/TrainingSet
/TestSet/
  - /Test1Set
  - /Test2Set
  - /Test1SetContours
  - /Test2SetContours

Enter the source code directory and run data_preprocess.py, automatically processes the RVSC dataset into a trainable format and performs data augmentation. You can specify the times of data augmentation with the -t option.

cd src
python data_preprocess.py -t 4

Training

In the source code directory, run train.py to start training.

python train.py \
--model unet \
--imgs ../train_data_aug/imgs/ \
--masks ../train_data_aug/i-masks/ \
--save ../i-checkpoints/ \
--epochs 50 \
--batch-size 64 \
--scale 0.5 \
-w 1e-4 \
-epc 5 \
-ls dice+ce \
-o adam \
--amp

If CUDA runs out of memory, please try reducing the batch-size or reducing the image scale. On the contrary, if the GPU resources are sufficient and you want to achieve better training results, try increasing batch-size, using the original image scale --scale 1, or removing the --amp option.

Predicting

python predict.py \
--pth ../i-checkpoints/unet_checkpoint_epoch50.pth \
--input ../train_data/imgs/P01-0080.png \
--scale 0.5 \
--viz \
--no-save

Evaluating a model on test dataset

python eval_test.py \
--pth ../i-checkpoints/unet_checkpoint_epoch50.pth \
--input ../test1_data/imgs/ \
--output ../test1_data/i-masks \
--scale 0.5

Segmentation results

After testing, the most effective model is UNet++. The following is a display of some segmentation results. The image on the left is the segmentation result of UNet++, and the image on the right is the real annotated data.

P33-0020-seg

P35-0140-seg

Acknowledgement

This project refers to the following code:

I would like to thank the authors for their excellent work.

License

This project is open source using the GPL-3.0 licence.

rvsc-medical-image-segmentation's People

Contributors

omigeft avatar

Stargazers

 avatar  avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

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.