Home

Awesome

HyperDenseNet

This repository will contain the code of HyperDenseNet, a hyper-densely connected CNN to segment medical images in multi-modal image scenarios.

Among others, this network is ranked first in the MRBrainS MICCAI Challenge http://mrbrains13.isi.uu.nl/results.php

If you find that this work has been useful for your research, please consider citing the following works:

A detail of a section of the proposed HyperDenseNet. <br> <img src="https://github.com/josedolz/HyperDenseNet/blob/master/Images/HyperDenseNet_Module.png"/> <br>

Content

Requirements

Running the code

Running the code actually works in the same way that LiviaNet. Just a reminder if you do not want to check the documentation from that net :)

Training

How do I train my own architecture from scratch?

To start with your own architecture, you have to modify the file "LiviaNET_Config.ini" according to your requirements.

Then you simply have to write in the command line:

THEANO_FLAGS='device=cuda0,floatX=float32,lib.cnmem=1' python ./networkTraining.py ./HyperDenseNet_Config.ini 0

This will save, after each epoch, the updated trained model.

If you use GPU, after nearly 5 minutes you will have your trained model from the example.

Can I re-start the training from another epoch?

Imagine that after two days of training your model, and just before you have your new model ready to be evaluated, your computer breaks down. Do not panic!!! You will have only to re-start the training from the last epoch in which the model was saved (Let's say epoch 20) as follows:

python ./networkTraining.py ./HyperDenseNet_Config.ini 1 ./outputFiles/HyperDenseNet/Networks/HyperDenseNet_Epoch20

Ok, cool. And what about employing pre-trained models?

Yes, you can also do that. Instead of loading a whole model, which limits somehow the usability of loading pre-trained models, this code allows to load weights for each layer independently. Therefore, weights for each layer have to be saved in an independent file. In its current version (v1.0) weights files must be in numpy format (.npy).

For that you will have to specify in the "LiviaNET_Config.ini" file the folder where the weights are saved ("weights folderName") and in which layers you want to use transfer learning ("weights trained indexes").

Testing

How can I use a trained model?

Once you are satisfied with your training, you can evaluate it by writing this in the command line:

python ./networkSegmentation.py ./HyperDenseNet_Segmentation.ini ./outputFiles/HyperDenseNet/Networks/HyperDenseNet_EpochX

where X denotes the last (or desired) epoch in which the model was saved.

Versions

Results

These images depicts some results included in the HyperDenseNet papers.

<img src="https://github.com/josedolz/HyperDenseNet/blob/master/Images/iSEG_Images.png"/> <br> <img src="https://github.com/josedolz/HyperDenseNet/blob/master/Images/WeightsNorm_1_0.png"/> <br>