Implemented boundary detection based on "Devil is in the Edges: Learning Semantic Boundaries from Noisy Annotations" (see link), generalized it to 3-dimension cases.
-
Basic 2D/3D CASENet network with weighted multilabel BCE loss
-
2D/3D Geodesic active contour inference
-
Iterative update between network training and level-set refinement
-
3D UNET (obsolete code)
-
NMS loss and direction losstr
- Setup configuration for 2D CASENet with 2D level set: training (link), testing (link)
- Setup configuration for 3D CASENet with 3D level set: trianing (link)
- obsolete configuration code: UNet3D traning(link), testing (link)
Clone this repo
git clone http://gitlab.bj.sensetime.com/shenrui/edgeDL.git
cd edgeDL
Install dependencies
Require Python 3.6+ and Pytorch 1.0+. Please install dependencies by
conda env create -f environment.yml
Preprocessing
Resample the data into same resolution. This code requires Free Surfer mri_convert (see link, Free Surfer installation guide).
./utils/resample.sh
Generate file lists for traning, validation and testing sets.
python data2txt.py
Traning
Setup configuration file and run
python train_casenet.py --config PATH_TO_CONFIG_FILE
Testing
Setup configuration file and run
python predict_casenet.py --config PATH_TO_CONFIG_FILE
-
Weighted multilabel BCE loss
where
: non-edge pixels/voxels ratio, : class : pixel/voxel -
NMS loss (edge thinning layers, to be implemented)
where
for normalization $x(p_t) = x(p) + t · \cos \vec{d_p} $ ,
: gt boundary pixel/voxel : normal direction at computed from gt boundary map Notes for implementation
- Normal direction: use a fixed convolutoonal layer to estimate second derivatives, and then use trigonometry function to compute normal direction from the gt boundary map
- code reference: edgesNMS(link)
-
Direction Loss (to be implemented)
where
: normal direction at p computed from prediction map
-
Level set evolution
solved by morphological approach (see link)
-
Energy (edge) map for level set alignment
where
: probability map predicted by neural network : (previous) ground truth annotation smoothed by gaussian filter with