Binary segmentation mask to centerline polydata using a python script

The code for saving the network curve with required folder structure is linked here.