Skip to content
forked from Sherry-SR/edgeDL

Implemented boundary segmentation with noisy annotations

Notifications You must be signed in to change notification settings

itrushkin/edgeDL

 
 

Repository files navigation

Semantic Segmentation with Noisy Boundary Annotations

Implemented boundary detection based on "Devil is in the Edges: Learning Semantic Boundaries from Noisy Annotations" (see link), generalized it to 3-dimension cases.

Implementation

  • 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

Configuration example

  1. Setup configuration for 2D CASENet with 2D level set: training (link), testing (link)
  2. Setup configuration for 3D CASENet with 3D level set: trianing (link)
  3. obsolete configuration code: UNet3D traning(link), testing (link)

Usage

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

Loss function

  1. Weighted multilabel BCE loss

    L B C E ( θ ) = k m β y k m log f k ( m | x , θ ) + ( 1 β ) ( 1 y k m ) log ( 1 f k ( m | x , θ ) )

    where

    β : non-edge pixels/voxels ratio, β = | Y | | Y |

    k : class

    m : pixel/voxel

  2. NMS loss (edge thinning layers, to be implemented)

    L N S M ( θ ) = k p log h k ( p | x , θ )

    where

    h k ( p | x , θ ) = exp ( f k ( p | x , θ ) / τ ) t = L L exp ( f k ( p t | x , θ ) / τ ) for normalization

    $x(p_t) = x(p) + t · \cos \vec{d_p} $ , y ( p t ) = y ( p ) + t · sin d p

    p : gt boundary pixel/voxel

    d p : normal direction at p computed from gt boundary map

    t L , L + 1 , . . . L

    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)
  3. Direction Loss (to be implemented)

    L D i r ( θ ) = k p | | cos 1 < d p , e p ( θ ) > | |

    where

    e p ( θ ) : normal direction at p computed from prediction map

Level Set

  1. Level set evolution

    ϕ t = g k ( κ + c ) | ϕ | + g k · ϕ

    solved by morphological approach (see link)

  2. Energy (edge) map for level set alignment

    g k = 1 1 + α f k + λ 1 + α σ ( y k )

    where

    f k : probability map predicted by neural network

    σ ( y k ) : (previous) ground truth annotation smoothed by gaussian filter with σ

Github reference:

  1. STEAL (link)
  2. edges (link)
  3. Morphsnakes (link)

About

Implemented boundary segmentation with noisy annotations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.7%
  • Shell 0.3%