-
Notifications
You must be signed in to change notification settings - Fork 3
/
guideline.py
71 lines (48 loc) · 2.83 KB
/
guideline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#-------------------------------- Variables ---------------------------#
# input to build the training set
path_data = '/Users/viherm/Desktop/CARS'
path_training = '/Users/viherm/Desktop/trainingset'
# input to train the U-Net
path_model = '/Users/viherm/Desktop/data/models/model_init'
path_model_new = '/Users/viherm/Desktop/data/models/model_new'
# input to train the mrf
paths_training = ['/Users/viherm/Desktop/CARS/data1','/Users/viherm/Desktop/CARS/data2', '/Users/viherm/Desktop/CARS/data3']
path_mrf = '/Users/viherm/Desktop/data/models/mrf'
# input to segment an image
path_my_data = '/Users/viherm/Desktop/data2segment/mydata'
#-----------------------------------------------------------------------------------------------#
from AxonDeepSeg.learning.data_construction import build_data
build_data(path_data, path_training, trainRatio=0.80)
#----------------------Training the U-Net from a path_training----------------------------------#
from AxonDeepSeg.learn_model import learn_model
learn_model(path_training, path_model, learning_rate=0.005)
#-----------------------Initialize the training-------------------------------------------------#
learn_model(path_training, path_model_new, path_model, learning_rate=0.002)
#----------------------Visualization of the training---------------------#
from AxonDeepSeg.evaluation.visualization import visualize_learning
visualize_learning(path_model)
#--------------------Training on (GPU Bireli)---------------------------------------------------#
# ---- In a terminal window ------
# $ scp path_training [email protected]:my_project
# $ scp path_model [email protected]:my_project
# $ cd AxonSegmentation/AxonDeepSeg
# $ python learn_model.py -p path_bireli_training -m path_bireli_model_new -lr 0.0005
# or
# $ python learn_model.py -p path_bireli_training -m path_bireli_model_new -m_init path_bireli_model_init -lr 0.0005
#- In a new window to visualize the training performances
# $ scp -r path_bireli_model_new path_model_new
# #----------------------Training the MRF from the paths_training---------------------#
from AxonDeepSeg.mrf import learn_mrf
learn_mrf(paths_training, path_mrf)
#----------------------Axon segmentation with a trained model and trained mrf---------------------#
from AxonDeepSeg.apply_model import axon_segmentation
axon_segmentation(path_my_data, path_model, path_mrf)
#----------------------Myelin segmentation from Axon segmentation--------------------#
from AxonDeepSeg.apply_model import myelin
myelin(path_my_data)
#----------------------Axon and Myelin segmentation--------------------#
from AxonDeepSeg.apply_model import pipeline
pipeline(path_my_data,path_model,path_mrf)
#----------------------Visualization of the results--------------------#
from AxonDeepSeg.evaluation.visualization import visualize_results
visualize_results(path_my_data)